« first day (352 days earlier)      last day (4599 days later) » 

1:10 PM
@TonyTheLion like, there's always sun, if nowhere else than above the clouds, yes?
 
so what exactly does std::piecewise_construct do? Constructs an object from a std::tuple using the parts of the tuple?
@AlfPSteinbach hehe yes
 
@TonyTheLion right.
@JohannesSchaublitb i gave all my cassettes to the salvation army. :-) i forgot to make a list :-(
 
@JohannesSchaublitb hey
@JohannesSchaublitb I have question, do you know if I have to add Memory barriers inside a critical section when using a weaker memory model, in order to be sure that all threads see what has happend to the variables inside the section?
If it's required, the critical section itself consists of memory barriers, so maybe they are not needed anyway?
 
@ManofOneWay ask on SO proper
 
@ManofOneWay im sorry I'm teh threads n00b xD
 
1:19 PM
Who is the thread expert then? =)
This is home of the hybris, so it must be someone in here ;)
 
there is or was a thread expert in clc++
 
awilliams
is on SO
but not on chat
 
@TonyTheLion Let's assume you have a type T that is constructible from int, long, double like so: T(0, 0l, 0.) or equivalently T { 0, 0l, 0. }
 
Yeah, Chris M. Thomasson, and also Anthony Williams as Johannes mention
 
1:23 PM
Then std::pair<T, T> pair(std::piecewise_construct, std::forward_as_tuple(1, 2l, 3.), std::forward_as_tuple(4, 5l, 6.)); constructs the two T inside the pair from 1, 2l, 3. and 4, 5l, 6..
You can also do std::pair<T, T> pair(T { 1, 2l, 3. }, T { 1, 2l, 3. }); but that's doesn't do the exact same thing.
 
@LucDanton so from a pair you can basically construct your T ?
 
@TonyTheLion From a tuple.
 
but your T would need to have a ctor that accepts a std::tuple<T,T> as an argument, right?
 
But a pair is a two-tuple so that works possibly.
@TonyTheLion Nope.
 
quick question
in a language that has ranged, specified as 10..20 (10 to 20).
 
1:26 PM
@LucDanton oh ok, can you show me a more elaborate example?
 
@TonyTheLion In my example the first element of the pair is constructed from 1, 2l, 3. which are picked from the tuple.
 
where you also want to allow users to specify floating point values as 10.
how would you prevent the ambiguity in 10..20 ?
 
@JohannesSchaublitb Make .. a token?
 
i.e it could be parsed as two floating point numbers next to each other. 10. and .20
by the maximal munch rule.
@LucDanton hmm it's already a token
user would have to write it as 10 .. 20 to prevent the ambiguity
but that's ugly
 
@LucDanton yea but you're constructing a std::pair here, not a T
which is what confuses me
 
1:28 PM
@TonyTheLion Well std::piecewise isn't really used anywhere else.
Still, the T's I mentioned were pair.first and pair.second.
i.e. constructing an std::pair<T, T> involves constructing two Ts.
 
question!
why is the type of SHRT_MAX int instead of short !?
 
No short literals? :)
 
@LucDanton so how would I amend this to use std::piecewise_construct ?
 
hmm good idea
 
@TonyTheLion std::piecewise_construct doesn't do anything. It's used by std::pair to avoid ambiguity in overloads.
if you have two tuples and do std::pair<T, U> pair(tuple1, tuple2); the two elements are constructed from the tuples directly.
If you do std::pair<T, U> pair(std::piecewise_construct, tuple1, tuple2); the two elements are emplaced from the tuple elements.
 
1:34 PM
with piecewise_construct you can have elements in a pair that are neither copyable nor movable
 
Hi, is this a C++-only room? I don't see any active rooms for C.
 
This is a room for chatting.
 
lol
ah nice. now there are only 5 non-wiki answers of "c++0x" tags of me left
one answer is about concepts. I wonder where the other 4 answers are...
 
Don't change the one about concepts.
 
I kept it C++0x because C++11 has no concepts
 
1:37 PM
Right.
 
Don't forget to retag questions you haven't answered, too!
 
damn university
are their staff ever available?
 
hey, im in a crunch and this assignment is due pretty soon
 
@DeadMG Yes, it sucks, same here. I've been chasing people all day
 
im getting a segfault
from this
 
1:40 PM
my father's harassing me about it too
I got a thing saying I'd hear back by the end of the day
 
(currentStudLoc->next)->data.compare(otherStudent)
 
he wants me to call them up because it isn't here by 2.30
 
its a linked list and im trying to delete a node
 
Once you get hold of them, they hardly know anything anyway
 
or they can't help you and try to forward you to someone else
but that someone else isn't here and you already tried to leave them a message
 
1:41 PM
Yes
Always the same thing
 
@StephenGranet How on earth are we supposed to help you if we can hardly see any of your code?
go write up a proper question
 
Today I got hold of the Director of Studies, so hopefully I will progress
 
@LucDanton no xD if everyone retags his own questions we will be done
with multi tasking applied successfully
 
I didn't expect you to help with that code snippet,i was asking if anybody was willing to help with the question, and i could post more code, but did not want to bog down the chat. Thanks though
 
@LucDanton hmmm ok. like this then?
 
1:43 PM
@StephenGranet Putting a link to a paste from a site like ideone.com is a good compromise.
@TonyTheLion That's more like it, yes. Add some template parameters :)
 
@LucDanton i can offer services. for every 100 transisted answers I get 10 euros
lol
 
@LucDanton wasn't sure which ones?
a pair is only two, but my tuples have three
 
@TonyTheLion std::pair is not a type.
 
@LucDanton oh...
 
Well presumably you want an std::pair<T, T>.
 
1:46 PM
oh right
so now I have this funky error: ideone.com/2Omos
it says piecewise_construct is not a member of std::
which it obviously is, right?
 
GCC doesn't implement that std::pair constructor; I believe (but I may be wrong) that it requires delegating constructors.
 
@LucDanton oh
 
I should have mentioned that earlier but it completely fell off my mind (and I compiled my example in my head only).
 
damn, never done delegating ctors
 
Problem being that when you accept a tuple in a variadic template you can't unpack it.
 
1:50 PM
oh jeez
so the delegating ctor is supposed to solve that?
or is that a problem with delegating ctor?
 
Yes, a delegating constructor solves that.
You can try if you want: write a template that accepts a tuple and constructs a type from the elements of the tuple.
 
Or you accept it with template<typename T> void f(tuple<T...>) { } then you can unpack it
 
@JohannesSchaublitb Show me how you do that :)
 
T...
oh wait. I see what you mean now!
 
The tuple, not the pack.
 
1:54 PM
Either I'm missing something obvious, or this is an interesting question.
1
Q: How do I write and ADL-enabled noexcept specification?

R. Martinho FernandesImagine I'm writing some container template or something. And the time comes to specialize std::swap for it. As a good citizen, I'll enable ADL by doing something like this: template <typename T> void swap(my_template<T>& x, my_template<T>& y) { using std::swap; ...

 
For a short amount of time I can say "I'm on the 13th place on the quarter/year toplist this time!"
lol
 
@RMartinhoFernandes That's like using ADL for the return type. You can't.
So, you need a trait.
 
Oh, right!
 
> Just because one can, does not mean one should.
 
Please do write up an answer.
 
1:56 PM
sums up C++
 
@RMartinhoFernandes Going through my answers first, to link if I find a ref.
 
@RMartinhoFernandes for that example you don't need a using declaration at all if you first forward declare the template I believe.
ah wait. it will not be std::swap. dang :(
 
now are delegating ctors a new C++11 feature then?
 
Even if it's in another namespace?
Although you could still introduce a dummy template<typename Lhs, typename Rhs> void swap(Lhs&, Rhs&);
@TonyTheLion Yes.
 
yeah but it's not std::swap :(
 
2:00 PM
@LucDanton hah, I learned yet another thing, in this conversation we've been having :)
 
you could write the using declaration at namespace scope but it's ASS UGLY
 
@JohannesSchaublitb Huh, the problem isn't the using declaration though. Or am I not understanding?
 
hm. for ADL to be active it needs to find a function declaration that is not a local non-using declaration / member declaration.
but you still need a std::swap fallback.
 
@LucDanton obviously not a variadic temple, but one that takes a T in it's tuples?
 
2:02 PM
so if you place the using declaration at namesapce scope it will work
 
The standard library can get away fine by being inside namespace std.
 
since it will combine both requirements into one using declaration
but that's ASS UGLY
 
@TonyTheLion Not variadic in the number of elements it takes, no. Variadic in the sense that it has a parameter pack, yes.
 
but Luc's trait trick might do it.
 
I'm still confused :( I thought using std::swap; swap(foo, bar); would use ADL.
 
2:03 PM
Yeah. I think that's the answer.
@LucDanton It will. And fallback on std::swap, in case no swap is found in the associated namespaces of foo and bar.
 
if you make a namespace tricks { using std::swap; template<typename A, typename B> void swap(A&a, B&b) noexcept(swap(a, b)) { } } and call noexcept(tricks::swap(x, y)) in your template
 
@JohannesSchaublitb Clever.
@RMartinhoFernandes Answered.
 
so what are some good uses of the preprocessor, cause I've heard of a lot of bad things about using macros'?
 
When there's no alternative?
 
Repetition, as in busy-work.
I always get scared when I decide to use bullet points (like I did in my recent answer), I can't remember English typography rules :(
> In British English, the word following the colon is in lower case unless it is a proper noun or an acronym, or if it is normally capitalized for some other reason. However, in American English, many writers capitalize the word following a colon if it begins an independent clause (i.e., a complete sentence).
No wonder I get confused.
@JohannesSchaublitb Do you think your clever trick should belong as an answer?
 
2:19 PM
@LucDanton race condition
:)
 
It is a good compromise over just the two choices I mentioned though.
(Type traits as a workaround for decltype feels dirty for instance.)
 
'Luckily' for me I don't have to rewrite all my code that uses my hand-rolled tuple_element as I have a real need for it :)
 
Mine is value-category aware, whereas std::tuple_element only takes care of cv qualifiers.
That and TMP with tuples.
 
I've reimplemented Boost.Phoenix!
C++11 features make that really easy to do.
 
2:49 PM
Okay, I just finished installing Windows 7. For the second time. Now it works :)
Runs smoothly with 2 GB, I don't think I'm gonna bother installing the other 2.
But I haven't installed the huge applications yet, maybe I'll change my mind later :)
 
@FredOverflow if/when the calendar widget stops working, regsvr32 vbscript.dll and reboot.
 
3:07 PM
@AlfPSteinbach What calendar widget?
 
hi i want build this array a[200][200][200] with dynamic memory allocation how can i do this>
 
You may need it, but tri-dimensional arrays fire up some red lights in my brain.
 
@JackJacky What is the element type?
 
Als
Hola!
 
@JackJacky std::vector<T> a(200*200*200);
 
3:14 PM
std::vector<std::array<std::array<T, 200>, 200>> a(200);
T being the element type.
Don't forget to include vector and array.
 
@FredOverflow Why not arrays all the way?
 
@Als ohla
 
argh
 
Oh wait, dynamic allocation.
 
my parents are giving me a really hard time over the university thing
 
Als
3:16 PM
@TonyTheLion: holer!
 
@RMartinhoFernandes would probably blow the stack
 
@Als what's up?
 
@JackJacky If you're a masochist, you can also do raw C arrays:
int (*a)[200][200] = new int[200][200][200];
// ...
delete[] a;
 
@DeadMG oh... :(
 
Ceiling.
 
3:17 PM
like
what the fuck do they want from me? I can't magic up more people on the other end
 
i want to simulation a physical phenomenon so i need this array
thanks alot
 
But then you must take care of exceptions that might happen between new[] and delete[].
 
Als
@DeadMG: What happened pup, You seem worked up?
 
@DeadMG what your parents want from you? Probably that you got the degree
 
well
basically my mother came in and shouted at me for not having my results
 
3:18 PM
Did you ditch university?
 
Als
Not having your results from where?
 
university
 
oh, you mean you haven't got them from uni? or you haven't got the results she expected to see
 
term's started now too
no, I haven't gotten them at all
 
How is that your fault?
 
3:19 PM
apparently, there's only one guy in the whole place who, according to their system, is actually capable of solving the problem
and he's never there
I don't know
 
Als
@DeadMG: lol
 
What problem?
 
oh lol
 
Als
this is like comedy of errors
 
well
 
Als
3:20 PM
I mean I am sorry but I don;t see how it is your fault?
 
the university think I owe them money, and they're wrong, in short
and they won't do shit until it's corrected
 
Als
geez greedy Uni
 
well
wtf do my parents want me to do? I can't magic people up or make them contact me or make them solve my problem
 
Als
hmm...parents never understand those things really
 
well
tbh, the whole fucking thing is just
 
3:22 PM
@DeadMG What does "magic people up" mean?
 
I'm attending this course for nothing of any use anyway
@FredOverflow Create people that their shitty system says can solve my problem from thin air
 
Als
@DeadMG: Now thats a different thread pup
 
@Fredoverflow can you write me a simple code and define a[200][200][200] with double type this is very important for me thanks.
 
Als
@AlfPSteinbach: Peek in when you find time, You owe me an explanation please.
 
lol, there's this RAM manufacturer called "GEIL". In German, "geil" means "horny" :)
@JackJacky lol just replace int with double?
 
3:25 PM
horny manufacturers of RAM :)
 
double (*a)[200][200] = new double[200][200][200];
// ...
delete[] a;
 
@FredOverflow Wait, you can't use that as an interjection anymore?
 
@JackJacky there you go
@LucDanton what?
 
Als
Is this a valid statement to make You can assume virtual dispatch is disabled in constructor and destructors. from a users perspective not the pedantic perspective. And if not why?
 
@FredOverflow 'Geil'.
 
3:26 PM
the virtual type of the object is the object being constructed
 
@Als Seems good enough to me.
 
but you could still, for example, call a base class function that dispatches to a virtual function and get the derived class override being called
 
@LucDanton I don't know what you mean.
 
Als
@RMartinhoFernandes: Thought so
 
@DeadMG Really? I thought the vtable wouldn't be set up yet or something?
 
Als
3:27 PM
@DeadMG: Indeed but that would require more than just calling the function normally
 
no
the Standard is quite explicit, iirc, what I wrote above is nearly word for word
@Als true
 
Als
Oh well the point is, @AlfPSteinbach disagreed about this in an answer today and downvoted me even
so wanted to get an explanation of why so
 
Well, you can get all pedantic about the wording.
 
well, it certainly won't call the most derived like normal
 
@LucDanton Oh, do you mean "geil" as in "cool"? Yeah, that also works. "geil" is overloaded :)
 
3:29 PM
but as far as I know, it could still call the current derived, as it were
 
@Als Given class Derived : Base and a Base* a;, if you're in the ctor of unrelated class Foo and call a->frob() you still get full virtual dispatch.
 
Als
@RMartinhoFernandes: Yeah I mean but as far as I know Alf ain't a pedant so..
 
@fre
 
@jac
 
@FredOverflow Because I reall wouldn't have picked up the 'horny' meaning here.
 
3:30 PM
@fredoverflow thank you very much.
 
@LucDanton Well, us C++ nerds tend to be more horny than cool, so...
@JackJacky you're welcome
 
@Als So, virtual dispatch is not exactly disabled, but it won't work as normal on this.
 
Does it work on this+0? :)
 
Als
1
A: Calling Inherited IUnknown::Release() in a destructor

AlsCalling virtual functions inside the constructor or destructor does not call the function you assume it will call. It always results in call to the functions of that same class. You can assume virtual dispatch is disabled in constructor and destructors.

 
3:32 PM
By the way, my Sound Blaster doesn't work on Windows 7, but my onboard sound does, so who cares.
 
Als
@RMartinhoFernandes: Alf was fairly clear on his NO, read the comments there, if you can
So I was wondering why he says NO
 
lol, "My dear Mr. singing club!" means "Ye gods and little fishes!" :)
 
@Als Maybe because it's just on this that it doesn't work and not in general?
It even works on other pointers or references to the same type.
 
If you call Base::virtual_member() you still end up in *this. You don't get 'lower-down' because it's not constructed yet, but you still get some dispatch.
Mmmh that won't work as advertised.
 
Als
@RMartinhoFernandes: Ofcourse only on this, now associating the rule with other pointer or reference would be pedantic...
 
3:38 PM
Well... It's a dent on your general assertion.
 
11 mins ago, by DeadMG
but you could still, for example, call a base class function that dispatches to a virtual function and get the derived class override being called
So you do get dispatch, just not further down than *this (which can be problematic if the type is abstract).
 
Well, IMO calling virtuals in ctors is always problematic.
 
yes
and the compiler is not required to diagnose or anything in that condition
 
Als
Hmm...
 
it's just UB
 
3:40 PM
Is it UB?
 
Als
How is it UB?
 
In C++ it's problematic because it doesn't work as expected; in languages where it works as expected it's problematic because you have no idea what the code will do, and your object is still being constructed.
 
Als
You cannot call something that is not constructed yet
that's not UB
 
@Als no, not really. you should be able to look up such things. especially when you have written an answer for others.
 
Als
@AlfPSteinbach: Huh?
 
3:41 PM
that said, i would not be here if i did not usually help other people. so.
 
@RMartinhoFernandes It's not problematic in C++ (it's not like constructors of an abstract class should do much); it's too bad there's not an option to run a second phase of construction but that's what you get for doing advanced OOP in a multiparadigm language.
 
Als
@AlfPSteinbach: I should be able to look up which things? And which answer you refer now
 
you can start by defining what you mean by dynamic binding (whatever you called) outside constructor/destructor. define it so that you can defpositively say here it is, and here it is not.
then apply your definition to destructor and see if things are different. they are not.
 
Als
@AlfPSteinbach: How? A code example?
 
code examples are good
 
3:44 PM
Oh calling virtuals in dtors sounds even worse.
@LucDanton Yeah, language supported two-phase initialization would be nice. I think we talked about this before.
 
Als
@AlfPSteinbach: Yes, So a code example, which disapproves the assumption I made.
 
We did!
 
@AlfPSteinbach They are different. The object does not completely exist in the base class destructor.
 
Als
@AlfPSteinbach: Or If you just chose to be pedantic on this, we could as well stop the disscusion
 
@DeadMG don't bullshit here
 
3:46 PM
there is no bullshit, it is what the Standard says and logically how implementations must act to be safe
 
@Als i'm not pedantic. you're veering away. the thing is, it works exactly the same.
i'm just asking you to demonstrate that
 
Als
@AlfPSteinbach: Could you please give a code example which disapproves the asumption?
 
you wrote in your answer "You can assume virtual dispatch is disabled in constructor and destructors", and that is 100% incorrect.
for example, off the cuff
struct Base
{
void foo() { v(); }
virtual void v() { say( "Base" ); }
 
};
struct Derived: Base
{
virtual void v() { say( "Derived" ); }
 
Als
3:49 PM
@AlfPSteinbach: Geez man, Ideone!
 
~Derived() { foo(); }
};
 
Als
you are spraying the code all over lol
 
if virtual dispatch was disabled, the Derived destructor should not be able to get a virtual dispatch down from Base::foo. however, it you try it (and fix any typos) you will see that it works just as usual.
 
no, that's not true
if there was a mostderived that also overrides foo, it's overload would not be called
in addition, in ~Base(), any foo() will dispatch to Base::foo()
 
@DeadMG foo is non-virtual and cannot be overridden. hello.
 
3:51 PM
whoops, I meant v()
 
can you call a dtor using this->Base::~Base(); ?
 
Als
In ~Base() any v() call will result in calling Base::v()
 
@DeadMG you have some misconception about this. you can just read the FAQ. the main thing to learn is probably: that during construction and during destruction of T, the type of the object is T.
 
and if Base::v is pure it is UB
 
@Als right
@JohannesSchaublitb right
 
3:53 PM
note that each base class is an object of type TheBaseClassType
 
@AlfPSteinbach That's exactly what I just said.
 
but the most derived class is of type TheBaseClassType during TheBaseClassType's constructor and destructor call
 
Als
So how does it dent the assumption?
 
@DeadMG no, you said "no, that's not true", which is meaningless
 
Als
A virtual method called in constructor or destructor of an class results in call to the function of the same class..always
 
3:55 PM
or of a base class
lol
 
@AlfPSteinbach That's not a very straightforward explanation. After construction (and before destruction), there is still an object of type T, namely *this.
 
@JohannesSchaublitb Or of some other class!
 
@RMartinhoFernandes ohh right!
 
or maybe I memcpy changed the vptr!
 
That's not well-defined behaviour.
 
Als
3:56 PM
Honestly, I am not convinced how the assumption is wrong and how it fails.
 
@Als i'm wondering if you're there at all? you have just had demonstrated to you by concrete code that what you wrote was not true. that the effect that you predicted would not happen, did not fail to occur. and i've given you the relevant faq urls. what more do you require?
 
what assumption
 
@Als Virtual dispatch still works in ctors and dtors. Do you agree?
 
@RMartinhoFernandes but not for "this"
 
Als
3:57 PM
@RMartinhoFernandes: It does, just you can assume that it does not so that you can estimate what the behavior will be for an user.
 
hm, i suppose it works but not really :)
 
@JohannesSchaublitb it does
 
The dispatch ends up at most at *this, but it's still dispatch in a sense, yeah.
 
well, it certainly doesn't behave the same as outside a con/de structor
 
yes it "works" but it doesn't really
 
3:58 PM
@Als did you not understand that your "estimate" is unable to predict the effect of the code i typed at you?
 
Als
thats the point it works but it doesnt really and hence the assume
 
@Als it works and it really does work and there's no point ub assuming anything else, that's just daft
 
if you call a base class function from the ctor/dtor, the base class can do this->f() and virtual dispatch can "lift" control up into the derived class again
so it kinda "works"
 
Would changing that sentence to "Virtual dispatch in ctors and dtors doesn't work as you would normally expect." make everybody happy?
 

« first day (352 days earlier)      last day (4599 days later) »