« first day (556 days earlier)      last day (2297 days later) » 

12:08 AM
@crasic the compiler, in that case
 
Thanks for your help guys. I talked to a colleague and they were able to clear things up for me. Apparently we can read in configuration files at runtime, I didn't know that. 👍🏼
 
20 messages moved from Lounge<C++>
 
I'm using boosts property_tree to read an xml file.
 
No you're not. For reasons I can't get into.
2 messages moved from Lounge<C++>
 
 
9 hours later…
9:26 AM
hi. Is there a way to capture exception without throwing anything? I mean, from where I can get std::expcetion_ptr other than std::current_exception()?
 
@sehe thanks, overlooked that
How bad it will be if done in a loop? I have a queue of threads that subscribed for data using std::promise, and when producer closes, I'd like to wake up people waiting on futures, and there can be many of them
 
Well. It's "just" thread synchronization primitives there. I'm not sure what the exception info has to do with it.
 
can 1 rep people chat?
 
@Incomputable 20 rep
 
9:30 AM
crap ... so it is not possible to bring newbies here
 
Nope.
I know you mean the guy with the TextThread. He's lost. I'll just ask a few follow ups there
 
@sehe I just thought that people could also need to pass exceptions through the pipe. For now it supports only noexcept move types, but I thought that I could abuse std::promise.
 
What pipe?
 
@sehe interthread communication pipe. Basically a queue of data protected with mutex. It also has a queue for those who are waiting for data to arrive.
about your question on CR, may be regex-like formatting could help? Then one could make "sticky" flag for the stream, which will use it if stream encounters the input
 
Hmm? I'm not doing input.
 
9:37 AM
oh sorry, output
 
It's not even about doing output. Though it's about code patterns that arise very often in writing output code.
It's specifically to avoid code like
bool first = true;
for(auto i : s._data) {
    if (!first) os << "|";
    first = false;
    os << i;
}
I hate the explicit state. It leads to brittle code and noisy code.
 
ah, I see. People tried something like that on CR, let me find the link
 
@Incomputable Please - not about "how to join (xxx) with delimiters". It's not that. It's about how to implement that cleanly (not how to not write it)
 
there was something about wrapping the container and that would signal the stream that it should not do something
 
not sure what to feel about sep's conversion operator having side effects
 
9:41 AM
like print_view{container}
 
@Incomputable I'm not printing containers. I'll clarify the question later, because you're not the first to make that interpretation
 
I'd probably write it like sep() (that is, using operator())
 
@milleniumbug It is like that in 60% of the code ;)
So, that's a valid reply.
It's also a bit iffy to have mutables, IMO.
But that's just to make using it in a lambda capture convenient.
I'm looking for a set of primitives that could, ideally, composite well (like every_nth(";", first("", " ")) or something)
Or at least, I'm looking for a pattern that affords that (inb4 monads) so that I can write the primitives that I do use in the right fashion
 
@sehe can't ranges do something like that?
 
That's actually literally in my question. I'm not sure.
I have that intuition (for the same reason I said "inb4 monads") but I'm not versed with that to think up "how"
 
9:45 AM
sorry for not reading thoroughely, my astrophysics professor fried my brain today with his insane math
 
one_off could be viewed as a concatenation of single-element sequence "" and an infinite sequence of ", "
 
yep
somehow wanted to write that, but you were first
 
@ОксанаВолинець, threads only accept callable objects, like functions and lambdas. You're passing threads again. It is not correct. — Incomputable 10 mins ago
@Incomputable no he isn't.
Clearly he's dreaming of passing some kind of index range.
 
@sehe I guess it is one of those cases where one needs to sit down with her and ask what every line does. And then correct the misunderstanding. Ocsana is russian female name :)
 
@Incomputable Not at all. I've done that in 5 minutes. The point is, nobody knows for sure what the goal is (at least the OP doesn't know)
 
9:51 AM
after reading your latest comments, it seems so. She also has severe problems in simple code. It is a miracle that my library has a librarian which I can ask to buy some books for the library
the library will even have the latest edition of C++ templates: the complete guide
 
Nice
 
nwp
That's what libraries are supposed to do.
Sometimes they even fulfill some of their duty.
 
I'm trying to find a way to attend CppCon this year, but it seems like I need to do something incredible for university to sponsor it. Some people attend conferences, but I've never heard of anyone attending CppCon yet.
 
10:06 AM
Submit a lightning talk
Or you know, pay the entrance fee
 
10:19 AM
@sehe I live in Kazakhstan, which is, I believe, one of the furthest countries to US. The country is located to the South of central Russia, nearby Caspian sea
 
 
2 hours later…
12:15 PM
In constrast to most Americans, we do know where Kazachstan is
@Incomputable plink (forgot)
 
@sehe it's not that we don't know where, its more.... Borat
 
You're not a merkin :) You're disqualified
Oh. Maybe you are.
@Mgetz Huh. I always archived you into the same bucket as the euro-germans
:( sorry
 
@sehe I was wondering how long that realization would take. @JerryCoffin and I have talked about Colorado a few times. ;)
@sehe apology accepted
 
It also has to do with the online times.
I suppose I see you too often during the day, and too little during the night for it to dawn on me
 
nwp
(heh, dawn)
 
12:21 PM
@sehe I tend to work more east coastish hours because of clients
 
 
2 hours later…
2:18 PM
What is the purpose of string_view?
 
@SzymonMarczak to provide a non-owning slice of string or char*
that also has a length attached
 
@Mgetz ok, already know that, but could you provide me a real example? For example in what you case you'd use that?
 
@SzymonMarczak literally anywhere that currently takes const std::string& as a parameter
 
@Mgetz What's the difference between string_view and const std::string&?
string_view does the same job like const std::string& right?
 
but you can't pass a const char* to a const string& without allocating
 
2:24 PM
@SzymonMarczak string_view is non-owning, so if I pass a char* to a method taking one it won't create a copy. const std::string& will
 
@Mgetz Why it'll create a copy? You pass a reference to it...
 
because the conversion from char* to std::string requires a copy
 
@SzymonMarczak because a std::string is owning
 
@Mgetz ok
So
According to this example:
 
7
A: When should I use string_view in an interface?

Mgetz Does the functionality taking the value need to take ownership of the string? If so use std::string (non-const, non-ref). This option gives you the choice to explicitly move in a value as well if you know that it won't ever be used again in the calling context. Does the functionality just read t...

 
2:27 PM
void foo(const std::string& x) {
// Is `x` owned here?
}

std::string y;
foo(y);
 
1 min ago, by ratchet freak
because the conversion from char* to std::string requires a copy
char*
CHAR*
CHAR*
 
@milleniumbug oh
 
@SzymonMarczak if you pass a value that qualifies as a non-explicit constructor input into a function taking a reference, the compiler will create a temporary to satisfy the reference
 
lol missed ratchet's message
 
std::string has a constructor that takes char* and is NOT-explicit
 
2:29 PM
generally the goal is to be able to write a function that accepts any string type that uses contiguous storage
 
@Mgetz That explains everything :)
@milleniumbug This explains it too :)
 
presumably later versions of QString will have their own conversion operator to std::string_view, for example
 
So, I can't append any character to string_view?
 
@milleniumbug no they'll just add a QString_view that handles their classes better
 
@SzymonMarczak it's a read-only view, so no
@Mgetz now that's just silly :D
 
2:32 PM
maybe @Mgetz is right
I just wonder why some libs perform faster than standard C++ libs, for example Boost, Qt etc...
 
"perform faster"? I don't think so
 
@SzymonMarczak depends on what you're talking about, some things do, some don't and it's usually behavior tradeoffs
 
@Mgetz yep, but why? maybe these functions are more strict?
 
@SzymonMarczak depends on what it is and how the behavior is intended to function. The stdlib has very tight behavior constraints
 
and libs can choose to relax some constraints to allow some optimizations to happen
 
2:38 PM
@ratchetfreak non-stdlib implementations can yes
but then they aren't standards compliant
 
3:03 PM
With -O3 flag my code runs slower, so does it mean that I wrote it badly?
 
slower than what
 
@milleniumbug slower than without -O3, nevermind i got that, some part was working faster, and the other was working slower, trying to fix it right now
24 hours ago, by Mgetz
@SzymonMarczak compilers are really good at recognizing common patterns, don't try to help the compiler
^^^^ THIS IS BEST QUOTE EVER ^^^^
I should print it and place it on the wall :D
 
the problem is on the line 42
2
 
@milleniumbug ?
 
The point is that rants are non-productive
if you had posted some code, one could possibly try checking why it runs faster or slower
of course you hadn't done that, instead, you're ranting
 
3:14 PM
@milleniumbug I'm still learning ;p i'll post code in a few secs
 
sometimes -O2 can be faster or slower than -O3, but, of course, without code we only can guess
 
@milleniumbug rewriting whole lib now
hating CMake so much
arghhhhh /try not to help the compiler/
    double d = 0.1;
//  std::int64_t n = *reinterpret_cast<std::int64_t*>(&d); // aliasing violation
    std::int64_t n;
    std::memcpy(&n, &d, sizeof d); // OK
so here
memcpy after optimisation does same job as reinterpret_cast
right?
@milleniumbug ping ^
I don't trust CMake now
 
3:31 PM
@SzymonMarczak yes. of course, now it raises questions like "why are you treating a double like an int64_t"
 
@milleniumbug I want to swap bytes
you can't swap bytes on double
but you can swap bytes on int64_t :)
 
in64_t are not "bytes"
char[N] are "bytes"
 
@milleniumbug i know that for now it kills portability, but I'm using __builtin_bswap64()
@milleniumbug int64_t stores 8 bytes
 
int64_t doesn't store "bytes", it stores numbers
 
@milleniumbug the only way to store int64_t is to store numbers from 0-255 which is one byte
@milleniumbug maybe that's better phrase: int64_t STORES numbers but it's built with 8 BYTES
if I'm wrong plz correct me
:)
 
3:50 PM
@milleniumbug You were right: in this case -O3 was slower than -O2 coliru.stacked-crooked.com/a/0aad9289eb13149d
 
4:28 PM
Hello, am noob. would like to humbly request some help with building a 'relocatable executable' with cmake
 
@BryanK It depends on what do you mean by relocatable .
 
@BryanK -shared -fPIC (usually)
 
@SzymonMarczak what Id like to do have cmake build the binary so that the binary looks for its dependencies in the present working directory of the binary its self. So I can have a folder with the binary and its dependencies that should work where ever its located on the system or other systems
 
And what made you decide you shouldn't search on Stack Overflow/google?
@BryanK Also, that's usually known as a static link, and few libraries support it. Other kludges are all related to non-portable influencing of the dynamic (runtime) linker.
 
well I have a post on stack overflow. And currently googling... First time trying the chat
 
4:40 PM
Linker flag -rpath comes in, LD_LIBRARY_PATH on linux, manifests/local dlls in Windows
 
@BryanK Check out this page rapidtables.com/code/linux/gcc/gcc-l.html I think this is what you need
 
@BryanK The question has def. been asked before. Many times. Look for "static link" or "static deployment" ("xcopy deployable" for windows afficionados)
@SzymonMarczak wow that's extremely entry level, I don't think that's what he needs since he's already using CMake
 
@sehe @SzymonMarczak Thanks
 
129
Q: How to add linker or compile flag in cmake file?

soltiI am using the arm-linux-androideabi-g++ compiler. When I try to compile a simple "hello world" program it compiles fine. When I test it by adding a simple exception handling in that code it works too (after adding -fexceptions .. I guess it is disabled by default ) This is for an android devic...

Assuming he's using GCC
then -L and -l will work
 
Come on. He was already looking. You shooting with blanks
Tip: keep noise down, otherwise "helping" has the adverse effect
 
4:45 PM
@sehe Doing a whole job for someone instead of "learning" isn't helping. And this wasn't shooting with blanks :) Check out GCC documentation.
 
?! Wow. You are not even fully aware of the question, and you tell me I need to read the docs. Something is odd here. Have fun
 
8 mins ago, by BryanK
@SzymonMarczak what Id like to do have cmake build the binary so that the binary looks for its dependencies in the present working directory of the binary its self. So I can have a folder with the binary and its dependencies that should work where ever its located on the system or other systems
"build the binary so that the binary looks for its dependencies in the present working directory of the binary its self"
 
5:04 PM
@SzymonMarczak ikr. Man you're noisy. It's not about ego. None of what you linked had relevance to that (he already uses CMake, he knows how to add options; you failed to mention the relevant topics (I doubt you knew, because why not mention /those/). [...]
Much more relevant, e.g. is the first comment on his actual question. But you know, I'm quite aware of your defensiveness and would appreciate to keep the noise down. Just in case you really wanted to understand my points).
 
@sehe Thanks for pointing my bad sides :) As @milleniumbug said, he learnt C++ by helping (/passing the knowledge from wise people to less wise/ or sth like that). I just wanted to help too. I didn't want to make some noise. And I missed your reply so I didn't know that you already made an answer.
 
yesterday, by milleniumbug
@SzymonMarczak passing knowledge from more experienced people in the chat to the less experienced people
I don't think I said it clearly...?
 
@SzymonMarczak That's not my reply though. Anyways, appreciating the good spirit! Cheers
 
Basically some time ago I was the "less experienced person"
and I was the one being taught
 
IMPOSSIBRU
(#metoo)
 
5:15 PM
@sehe sorry just mixed up the links
 
Then I get it :)
 
35 mins ago, by sehe
Linker flag -rpath comes in, LD_LIBRARY_PATH on linux, manifests/local dlls in Windows
 
Yup. I like to throw out googleable keywords. Also, because OP might narrow down the requirements
I'm going to make dinner, laters!
 
@sehe I must say your answer was the easiest way to achieve what he wanted, sorry for the noise. I didn't know what was in your mind... Ye, I'm still learning :|
@BryanK check out @sehe 's answer :)
 
5:37 PM
Just want to make sure, do constexpr says that the values returned by a function can be generated at compile time?
Also can I add excutable parameters to godbolt?
 
@SzymonMarczak basically, yes (though not guaranteed, depends on context).
@SzymonMarczak no
There's a go-to blog on online compilers somewhere
 
5:53 PM
@sehe ty but as you know godbolt shows you the code in asm ;) i just wanted to try some sort of experiment, but I think it'd fail; see this: coliru.stacked-crooked.com/a/2fba0cf9a03af2f9
is it possible to tell the compiler "hey, the function takes only 2 or 3 or 4 as a parameter"?
 
throw an exception if it's not 2, 3 or 4
 
@milleniumbug I forgot to mention that I want to use it as a template, please see this: coliru.stacked-crooked.com/a/c5c7692056f13ccd
 
square is constexpr, but your random generator isn't
 
6:21 PM
@milleniumbug And that's the problem, but is it possible to tell the compiler that it only takes 2 or 3 or 4?
@sehe @milleniumbug I wanted to get something like this: coliru.stacked-crooked.com/a/ebc104d186475f02
but to avoid if {} else if {} else if {} else if {} etc...
 
nwp
6:53 PM
@SzymonMarczak There are some techniques to avoid having to manually write the if-else chain.
 
7:07 PM
@nwp Black magic to me :D Can you explain what's going on with integer_sequence?
 
nwp
The core idea is to use an array of function pointers instead of the if-else chain. You then just index into the array with a runtime value and end up in the templated function with a compile time value.
A simpler version would be constexpr fn a[] = {&construct_constN<0>, &construct_constN<1>, &construct_constN<2>, &construct_constN<3>, &construct_constN<4>};.
 
@nwp Ok, now I get it :-)
 
nwp
And the integer_sequence is just there to generate the list of ints.
 
Amazing
 
 
4 hours later…
11:02 PM
I know this is a bit of a stretch but I badly need to know how to program with ffmpeg. Is anyone here good with the api. I can't even get all the headers installed. Where should I start, and what should I do? I'm working in c++ so thats why I'm posting here. Sorry this is a bit offtopic.
 
1 message moved from Lounge<C++>
 
nwp
11:15 PM
@user3600107 Did you go to their website and download the installer and run it?
 

« first day (556 days earlier)      last day (2297 days later) »