« first day (499 days earlier)      last day (2345 days later) » 

1:49 PM
Hi!
Anyone here familiar with Open MPI?
 
2 messages moved from Lounge<C++>
 
Never mind: I figured it out meanwhile.
 
 
1 hour later…
Ron
2:54 PM
Is this std::string s = "Some literal"; calling string's fifth constructor or does it employ strings assignment operator? I would think it's the prior.
I forgot to add that literal has an explicit \0 in it so it's actually "Some literal\0 this gets cuts off".
 
since this is declaration, then by definition it doesn't involve an assignment operator :)
the last overload looks interesting, haven't seen it before
 
Ron
I see. Appreciate it. Was answering a question and wasn't sure if I got it right.
Apparently I did.
High rep user said it was an assignment hence the confusion.
 
All that time it has used the const char* constructor, so the contents is indeed cut off
it's unlikely C++17 introduces a breaking change here
 
Ron
Apparently there is some confusion on this answer.
 
3:10 PM
hmmm
OP has
string a;
a="this is string\0 this part not assigned why?";
and their answer reflects the OP's code
 
Ron
My bad. I thought it was on the same line.
Thanks.
 
What is the reason for a lack of a const char[N] constructor? overload resolution troubles?
 
const char a[256] = "Some literal\0 this gets cuts off"; std::string s = a; // all the contents after null byte
void f(const char a[256]){ std::string s = a; /* no contents after null byte */ }
@ratchetfreak annoying and inconsistent
 
nwp
My guess was "But the Template bloat!!11 My poor compiler".
 
arguably this could be blamed on the "C legacy", but since char arrays decay, you have no choice but to rely on the C legacy
 
3:26 PM
when will the type of a string literal change to a string_view instead, that would be a lot more consistent
 
3:57 PM
Is there any special reason why a pseudo-destructor call is not a constant expression...? I think a compiler certainly can deal with it in compile-time!
 
1 message moved from Lounge<C++>
C++ features aren't constexpr by default
slowly more and more of features are constexpr, but that's because someone managed to convince the committee that these 1.) can be done at compile time. 2.) all the UB related to it can be diagnosed at compile time
 
Well, it seems there certainly exist some rationale behind it (such as, non-portability, having globally-visible side-effects, etc). Leaving it as a non-constant expression somewhat suggests there's a reason for it...
 
A lot of "why can't I do X" questions can be answered with "features aren't implemented by default" and "doesn't surpass the -100 points barrier" (a.k.a. "didn't pass the cost/benefit analysis")
 
So I just thought the fact that a "pseudo-destructor call" currently belongs to the list of forbidden constructs as a constant expression might suggests some rationale...:( I'm just trying to understand...!
Hmm. Alright.
Thank you for answering, though.
 
nwp
What is a pseudo-destructor call?
 
4:09 PM
A destructor call for a non-class type.
 
object_of_type_T.~T()
 
nwp
Ah, the WAT thing.
 
It might be good for me to consider it as invoking a function other than a constexpr function, thereby forbidden by the standard (although there's no function actually invoked)...
 
Food for thought: C++ has this rule that core constant expressions evaluated at compile time must be undefined behaviour free (more specifically, the one in the language, it's free to disregard this for standard library related undefined behaviour), or else you get a diagnostic
 
Just out of curiousity, what does "WAT" stands for?
 
nwp
4:15 PM
@Il-seobBae I think the reason is that new and placement new are not constexpr. Therefore there is no way to make compliant code if you manually called any destructor.
@Il-seobBae I don't know. I understand it to be equivalent to WTF and has evolved from people misspelling "what".
 
4:29 PM
Thank you for the comments guys~
 

« first day (499 days earlier)      last day (2345 days later) »