« first day (560 days earlier)      last day (4388 days later) » 

7:00 PM
So just to be clear, T t = t2 is the same as T t(t2) and T t = 4 is the same as T t(4) except that it requires a non-explicit constructor and a publicly accessible operator= that takes that argument but it doesn't use operator=
 
@Pubby Yes.
 
is that correct?
 
It usually is.
 
Wait, so is there ever a case where the elision can't be done?
 
T t = 4 is the same as T t(T(4))
 
7:00 PM
Maybe I shouldn't say "heil" anymore. This one was also flagged in the past:
Dec 8 '11 at 19:16, by WTP
Heil WTP!
 
@Pubby T a; T b = a; // no elision
 
@classdaknok_t Well, people are stupid.
 
@SethCarnegie It doesn't have to use operator= but it can. As a matter of quality of implementation compilers take great pains to avoid that.
 
@StackedCrooked Why can't that be elided?
 
What'd you want to elide here?
 
7:01 PM
@Pubby There are two physical objects.
 
It's supposed to make a copy.
 
But why use operator=?
 
It doesn't use operator=.
 
but it can?
 
You said it didn't elide it! :S
 
7:02 PM
@StackedCrooked An implementation can still choose to implement that in terms of T b = T(a); with no elision.
Although I'd better check.
 
I am confused now
 
Who isn't confused when dealing with C++?
 
Luc Danton
 
I'm don't feel confused due to my ignorance.
 
Ignorance and knowledge feel like the same thing
 
7:04 PM
Hi
 
how zen
 
So this shouldn't compile? ideone.com/xDSTt
 
Actually, scratch that, I'd need to check overload resolution rules and I won't do that.
 
Argh, why Konsole is annoying and highlights taskbar entry.
Lol.
 
@Pubby I don't think so according to what has been said recently
@Pubby nono, T t = t2 is exactly the same as T t(t2)
it's when T t = x and x != T that it needs the public operator=
I think
right?
 
7:06 PM
That might be the case. It might also be the case that's only true for C++11.
 
I'll try finding it in the C++03 standard
Whoaaaaaa I didn't know the asm declaration was in the standard
I thought it was only a compiler extension
 
This compiles too ideone.com/LXxE9
 
Then I think that one is the one that shouldn't compile
 
Well IMO it should compile and the standard committee should not make silly&confusing rules
 
@Pubby Ahaha.
Good joke.
 
7:10 PM
:)
 
@SethCarnegie It's funny, because in MSVC, it does nothing and you have to use __asm.
 
It's my understanding that there's a lot of inertia in the SC regarding that particular rule. The fact that this could have been relaxed for C++11 (when the source type is related to the destination type) is a miracle already.
how do I word with my keyboard
 
In an opposite way to boarding with your keyword.
 
@CatPlusPlus Well the standard does say that the use of asm is implementation defined and doesn't require anything else (it just says "usually it would be used to pass assembly instructions to the compiler" but that's it)
 
7:11 PM
why are the constructors of std::unique_ptr explicit?
 
so MSVC++ is conformant in that regard :)
 
@SethCarnegie Yes, it's useless.
 
doesn’t it make sense to be able to say e.g. unique_ptr<int> foo = nullptr;?
 
@KonradRudolph So non-owning pointers don't get converted accidentally.
Well, raw pointers.
 
7:13 PM
It has a separate constructor for nullptr_t.
So that should work.
But then again, it's the same as just unique_ptr<int> foo;
 
@CatPlusPlus That’s also explicit
 
@KonradRudolph It's not.
 
Ell
hmmm so it seems non-owning pointer != raw pointer.
 
ohh boy
@StackedCrooked why did you delete it!
 
@Ell non-owning pointer is a superset of raw pointer
 
7:15 PM
not true
 
Ell
which means, raw pointer might not be a non-owning pointer
 
a raw pointer neither owns nor non-owns
 
then I have no idea what an owning pointer is
 
@LucDanton Oops, jumped to the wrong line. You’re right
 
Ell
hence the need for std::non_owning_ptr<T>!
 
7:15 PM
or shall we say "it is not known whether a raw pointer owns or non-owns"
 
Ell
to explicitly state the semantics of it :L
 
Raw pointer should never own, unless it's an xvalue raw pointer. Or something.
 
Then whether it's owning or non-owning is not in the behaviour but in the intention?
 
And unless it's being used as an iterator.
 
Row pointers don't own and neither do they pwn. They rather suck in most cases.
 
7:16 PM
int *p = new int; delete p;
p was an owning pointer
 
@JohannesSchaublitb This is bad and you should feel bad.
 
That's a stupid thing to do.
 
@Ell We have that. It’s called std::unique_ptr
 
unique_ptr is owning.
 
7:17 PM
unique_ptr owns.
 
@KonradRudolph unique_ptr owns
 
unique_ptr is owning
 
Copydogs.
 
the only non-owning pointer i believe exists for general c++ seems to be weak_ptr
 
weak_ptr is the non-owning one isn't it
 
7:18 PM
for Qt there is QPointer
 
@SethCarnegie Damn, misread again.
 
Ell
but weak_ptr has something else about it
 
weak_ptr is supplementary to shared_ptr.
 
Ell
its more than just a raw pointer isn't it?
 
To break cycles
 
Ell
7:18 PM
yeah, stopping circular references or something such? o.O
 
It's non-owning shared_ptr, not non-owning pointer in general.
 
A non-owning pointer class doesn't make sense since it doesn't do anything. It's like a pair with only one element.
 
Like boost::fusion::pair?
 
@classdaknok_t It conveys meaning.
 
Ell
7:19 PM
@classdaknokt but we can use it to be explicit with the design and make the code more self documenting
 
it could guard you from using it outside the object lifetime
 
@LucDanton I can't find where in the standard it says something about T t = 5. I only see T t = t2 and T t(5) and T t; t = 5;
 
That's one of properties that we want from a good type system, and where plain T* fails.
 
null itself in that event etc
 
reference_wrapper?
 
7:20 PM
@SethCarnegie Well, if this is about C++03, I don't really want to know. For C++11, everything is in 8.5.
 
boost::optional<T&>, perhaps?
 
actually, i'm unsure
T* could be non-owning
 
For C++03 it's probably also in 8.5 anyway.
 
it is like weak_ptr
isn't it
what makes a T* non-owning or owning is the Q
 
#define @ * seems like a more convenient way to specify non_owning_ptr or maybe dumb_owning_ptr
 
Ell
7:21 PM
well you can split raw pointers in to non owning and c style can't you?
 
The form of initialization (using parentheses or =) is generally insignificant, but does matter when the
entity being initialized has a class type; see below.
I'm hot on the trail
 
@Pubby unless @ can be an identifier, you cannot do that. With clang you can use $ but it's dangereux.
 
What's so dangerous about it?
 
Here's how it goes: std::unique_ptr and the like are obviously owning, std::weak_ptr can give you an owning std::shared_ptr or a null std::shared_ptr (or an exception, hah), T* is non-owning (because), (T*, T*) is an iterator pair, (T*, some_integral_type) is a C-style iterator + length pair.
 
Might not be supported.
 
7:23 PM
@Pubby It breaks code that already uses it.
 
weak_ptr can throw exceptions?
 
"cv-unqualified type" means "the type after removing all the references" right?
 
There may be a defect in the specs.
@SethCarnegie No, after removing cv (as in const/volatile) qualifiers.
 
Sure. bad_weak_ptr when it dies before shared_ptr manages to increment refcount.
 
7:24 PM
@LucDanton ah ok
 
Well, shared_ptr throws that.
 
so that's what cv stands for
 
OK, next question: should I specialise std::shared_pointer_cast etc. or overload them in my own namespace (analogous to swap)?
 
ADL is probably better.
Specialising might be forbidden.
 
I shudder to think of the day where we might have cvr qualifiers :v void foo() volatile restrict&&; seems overkill.
 
7:25 PM
You're not supposed to touch std, much.
 
You can't partially specialize function templates, so that's a no-go. Go with ADL.
 
@CatPlusPlus Specialisation is explicitly allowed
@LucDanton Good point :)
 
What is the point of volatile member functions, actually?
 
Wasn't it only for some things?
 
@classdaknok_t They can be used on an object defined volatile.
 
7:26 PM
What he said.
 
@Luc Danton I know, but why would you need special functions for that? Why can't you just call all member functions on such objects?
 
Is volatile even useful for classes?
 
ADLing them is not too useful
because ADL only works for function calls
 
shared_pointer_cast is a function.
 
@classdaknok_t It works like const in this respect.
 
7:28 PM
"shared_pointer_cast<Type>(stuff)" is only a function call if "shared_pointer_cast" is a function template
 
@LucDanton I understand, but what is so special about volatile objects?
 
@LucDanton so you can't call non-volatile member functions on a volatile variable? I never knew that.
 
but if you use ADL to find your function, you have a chicken and egg problem
 
Right.
 
@classdaknok_t It gives power to writers of UD types to give semantics to those, much like semantics are given to const std::vector<T> compared to std::vector<T>.
Unlike with const though that might be more restricted, I haven't investigated that much.
 
7:31 PM
@JohannesSchaublitb Because it sucked.
 
is it valid to do vector<int> const a = {1, 2, 3}; *(int*)a.data() =10; ?
 
@Luc Danton I see. I've never used volatile though, so I'm not very experienced with it.
 
i mean, the element type is "int" not "const int" (which would not work)
 
@JohannesSchaublitb Given the specs for std::allocator I think it's guaranteed to work.
 
@JohannesSchaublitb my answer was basically: State & state = getState() evaluates to state&. If the State class has a conversion operator to an integral type then this will be used as the switch variable.
 
7:32 PM
ohh
i know your answer
i can still read it mwahaha
 
@Pubby volatile objects are useful when dealing with signals.
 
Wait, why doesn't vector have reference operator[]( size_type pos ) const; then?
 
because its elements are semantically const
 
@Pubby Signal handlers can only access volatile globals, otherwise the behavior is undefined. AFAIK.
 
It returns non-const reference, so it allows modification, so not const.
 
7:34 PM
But *(int*)a.data() =10; is allowed :S
 
@Pubby not everything that is possible needs to be allowed
 
@StackedCrooked only in the sense that the neighbour kid was son of a farmer and thought it would be interesting to make some loud bangs
 
UB is allowed by American Law :)
 
I'm pretty sure CISPA makes UB a criminal offense
 
i did not TRICK with that question..
I asked for my friend
 
7:36 PM
@classdaknok_t There are more restrictions.
 
@JohannesSchaublitb it was a trick
 
i find it fascinating that sin(M_PI) + M_PI is closer on PI than M_PI!
 
@JohannesSchaublitb but you still have to accept my answer :)
 
I'm wondering if a perverse allocator is allowed to check that its allocations are done for a const-qualified container and if so it can in fact break *(int*)a.data() = 10;.
 
i will do so on some days
 
7:37 PM
@JohannesSchaublitb so, why did you ask if you already knew the answer again? I'm still not clear on that
 
i mean, does the library even forbid it?
 
Or were you acting in accordance with your profile: "Sometimes, I'm trolling."
 
@SethCarnegie i found such a question does not exist yet
so i asked
i think that is a good thing
i don'T know why 2 guys downvoted me :(
 
M_PI doesn't exist.
 
The M_PI is a lie.
 
7:39 PM
@JohannesSchaublitb I upvoted you lol.
 
And should be a constexpr, not a macro.
 
I expected you to post an answer though.
 
mirror(314)
lol
 
I had to use acos(-1) and were sad.
 
Is char const[2] implicitly converted to int*?
 
7:42 PM
No.
 
Why would it be?
 
one woman asked me "Are you spain?" "Why?" "You look Spain!"
 
Spain is country, not a person.
 
and one guy a month later asked "Are you italian?" "You look like an italian."
 
1
Q: Integer pointers in C?

Pha3drusI am working with doing some serial communications in C in Linux. I am doing this using file descriptors. For some reason after char* s = "Hello world", I can write s to the serial port using the write method, no problem. I am using a serial monitor program to check the other end. However, I cann...

 
7:43 PM
what does this mean
 
Then this guy is using a bad compiler
 
@JohannesSchaublitb It's the tan.
 
Ah, GCC error messages, you so helpful!
> tests.cpp:16:34: error: 'raw_ptr' was not declared in this scope
> tests.cpp:16:34: note: suggested alternative:
> In file included from tests.cpp:4:0:
> ptr.hpp:53:19: note: 'base::raw_ptr'

(The offending code is `using base::raw_ptr;` )
 
 
7:45 PM
Korma is spicy?
 
@LucDanton it's on the bottom of the list
 
@LucDanton No, that's why it's way down below "Mild".
 
I must have found the wrong kind of korma :(
So you're saying they might as well have put a carrot. What's the point of that?
 
Korma ain't hot.
 
Kormas are supposed to be sweet and creamy
 
7:46 PM
"Oooh, now I get what 'non-spicy' means."
 
> Not to be confused with Karma.
 
I first read it as karma.
 
that bitch always gets me riled up
 
What bitch?
 
Karma
 
7:48 PM
I like this room because of its rich C++-related discussions.
 
Today was our monthly quota.
For May.
 
@Maxpm the C++ standard is more expansive than you thought
 
That's a tautology, almost.
You'd make a poor fortune teller.
 
Yeah, it's kinda like saying "most people are average"
 
ah, in 10mins the local TV shows "Nerd-Alarm"
it goes one hour!
 
7:50 PM
The key to happiness is dangling in front of you. Open your eyes and grab it. That will be $60 please.
 
ok, Indian restaurant now
how fitting
see you guys
and don’t choke on the spicy kormas ;)
 
"Von Gamern, Geeks und großen Brillen" lol
 
Big glasses aren't that common among nerds lately.
 
room topic changed to Lounge<C++>: Full of delicious spicy noodles. [c++] [c++11] [c++-faq]
 
More among dub step fans.
 
7:52 PM
full of big glasses eh
 
@classdaknok_t Yeah :)
 
Ell
arghh god damnit stupid people grrr arghhhhhh want to kill somebody!!! agsgiskjfajslgnasng!
 
@Ell Kill EVERYBODY — Skrillex.
We were talking about dub step anyway.
 
Ell
I wish I could :L apart from you guys. you guys are cool.
 
Hi. I have a print line ( cout << ... << endl) just before a function returns. It is occasionally showing up when I run the program. I have a similar statement at the beginning of that function, and it shows up a lot more. They should both show up the same amount, obviously. I am sure I am missing something obvious. I do notice when that function runs slowly, the latter print statement is more likely to appear, so makes me wonder if it is a flushing issue.
 
7:55 PM
std::endl suggests that it's not.
 
@FaheemMitha Obviously you have more than one return path.
 
Flush harder.
 
@DeadMG Good point. Let me check.
 
xD
Royal flush.
 
Lol.
A straight flush will do.
 
7:57 PM
@DeadMG : Yes, so there is. That's probably it. Sorry for the noise.
 
ace high flush
now I have a question for the resident C++ experts (other than myself, obviously)
 
if you have a std::set<T>, how can set.find(T) return set.end(), but set.insert(T).second is false?
 
Aliens.
 
Cats.
 

« first day (560 days earlier)      last day (4388 days later) »