« first day (357 days earlier)      last day (4607 days later) » 

4:00 PM
A member object can't be both const and static at the same time?
 
It can.
 
oh it works sorry typo
I had 2 publics
 
and when you only say "argument" and "parameter" the meaning is that "parameter" is the thing you declare and "argument" is that the thing you pass in
sometimes I cannot make myself upvote a perfectly fine answer, just because the answerer said things like "the parameter you give is an rvalue"
such a pity :(
 
If a parameter is the thing you declare then he is right..it is a rvalue
 
@JohannesSchaublitb Edit then upvote?
@LewsTherin The names of function parameters are lvalues.
 
4:03 PM
oops yikes
yeah
 
@LucDanton i fear that they may be offended if I edit them
 
@JohannesSchaublitb It's either that or comment but fixing an answer via comments alone can be tiresome sometimes.
 
sbi
Anyway, gotta go. Have fun here tonight!
 
@sbi have fun :)
Argh I have a member object which is both static and const, but when I try to initialiaze it outside the class it won't work... obviously but isn't there a way?
 
Usually it works like so: struct foo { static const bar member; }; const bar foo::member = expr;
 
4:06 PM
so i had to put the const again
 
you can also do struct foo { static const foo m; } foo::m{};
 
yeah it worked nice
what is that
foo::m{}
 
@LewsTherin const is part of the type (unlike static which works as a specifier in the declaration), then the type in the definition has to match the declaration.
 
@LucDanton specifier?
 
@LewsTherin Count the semicolons in Johannes' code.
And watch the types.
@LewsTherin By that I mean that static is part of the declaration, not of the type. const is part of the type (and then the type is also part of the declaration). Hence you must repeat const but not static.
 
4:09 PM
aww I have a bug
struct foo { static const foo m; } const foo::m{};
 
Why is static not a type
I mean it tells me m is a static type
 
What's a static type?
 
One that is class wide if it is a data member
 
hmm
how can a type be a data member
 
@LewsTherin Can you declare a pointer to such a type?
 
4:12 PM
You mean can I reference it? I think so...
 
don't be confused by typedef static int type;
 
I mean can you exhibit the type of a pointer to such a type?
 
ok sorry I still don't get you. :(
 
You claim there is such a type as a static type.
Then I ask you what the type for a pointer to such a type would look like.
 
i think he means types like int
as opposed to types like int[rand() % 5]
(which can only be specified with help by new)
 
4:17 PM
Ok static int *ptr = &m m of type static int
 
however, "static type" has a definite meaning for expressions in c++
and dynamic type too. and they have little to do with my comparison above, except for the fact that "dynamic type" can generally only be computed at runtime
 
@LewsTherin Then can you show what a class-wide int* member would look like?
 
static int *ptr ; it'd be declared inside a class like i think
 
Watchya arguing about?
 
@CatPlusPlus about some non-standard meaning for "static type"
 
4:20 PM
that static isn't a type
 
@LewsTherin But that would look exactly like a non-classwide pointer to static int data member :)
 
the notion that "static" would be a property of types is what this discussion is about currently
When used inside a function, the static keyword indicates that a variable is shared between all calls of the function. When used inside a class, it indicates that the variable or function is a member but is not tied to a specific instance. When used inside a namespace, it specifies internal linkage.
 
@LucDanton give me a few I'm trying to see it
I don't :(
 
struct foo { int* p; }; is a type with a data member that has type pointer to int, right?
 
why would it look non-classwide?
yeah
 
4:22 PM
Now make the type of the data member 'pointer to static int'.
 
@LewsTherin he means if static would be a property of a type, then static int *ptr would be a non-classwide pointer to an object of type static int, I think
 
static int *ptr lol ptr is a pointer to an int that is static
 
struct foo { pointer_to_static_int p; }
 
oh
uh
 
4:24 PM
Now that doesn't mean it's impossible to make that work, but I showed you that given where static currently appears there's an ambiguity if static is part of the type.
 
you can do that with functions
 
Wait I still don't get it...I'm reading it
 
typedef void function_void_no(); struct foo { function_void_no p; };
but not with static, because that would not make sense
 
ok I'd type it myself
class {int *p} ;p is a pointer to an int
class {static int *p} p is a pointer to a static integer...but p is not static lol
 
I wonder why if I put sugar into yoghurt, the yoghurt always warms up a bit
 
4:26 PM
oh
 
Sugar is meh.
 
so p itself is not static but what it points to....
 
Yes, you'd need class { int* static p; };, but that's not allowed.
 
What the hell is static integer supposed to be?
 
why make it so complicated
 
4:27 PM
Why is it not allowed
 
@LucDanton for that example it too can be said "the type of the pointer is static, not the pointer member itself"
 
16 mins ago, by Lews Therin
I mean it tells me m is a static type
@JohannesSchaublitb Yes.
 
note that class { alias<int*> static p; }; is allowed
 
So because there is ambiguity what is really static in a pointer case, static is not a type
or part of a type
 
@LewsTherin no not because of an ambiguity
 
4:30 PM
Admit it, you're all drunk.
 
but because of fundamental logics
lol
 
@CatPlusPlus I admit to nothing. Also, I'm not drunk.
 
you are a drunk guy who is in not
help is in order!
 
what fundamental logics
 
i think just apropos of nothing that an idiot embedded in an academic setting, can appear normal -- until the person fails to grasp something fundamental, such as left versus right
 
4:32 PM
I started from the premises and showed how with the current grammar there is an ambiguity. That's a demonstration of how static is not part of the type.
 
@LucDanton it is not
 
Ambiguous?
 
@LucDanton if in static int *p, the static is part of the type, what else would it mean?
it would mean that static is part of the type
 
@AlfPSteinbach correspondingly, i think this also holds for an idiot embedded in a management layer, although in that case it may be what we are expecting anyway, so true colors revealed much faster
 
and int * static p would also mean that static is part of the type
but it would not be ambiguous
 
4:34 PM
Right but I said 'with the current grammar'.
I know static could be turned into a type qualifier.
 
with the current grammar there is no ambiguity
 
as i recall you can't have static after *
 
if there is, I would like to ask you to send a DR!
 
@JohannesSchaublitb Well which is it, DR or compiler bug report?
 
@AlfPSteinbach if the grammar allows that, there is no ambiguity
 
4:35 PM
@JohannesSchaublitb yep but i don't think it does. test with comeau...
 
@AlfPSteinbach right the grammar does not allow it
 
identity<int*>::type works though, no need for template aliases.
 
it does not need to because static is not part of the type
 
Bloody hell, grr you guys lost me lol
 
4:37 PM
I see your point. I still think the demonstration is valid: since the (conforming) compiler doesn't accept the code, the premise is wrong.
 
See, I told you, you need to be drunk to follow this conversation.
3
Oh, cool, PyPy is planning to do concurrent GC.
 
i think i'm going out to test the beer/food at mexican cafe 60 meters from my balcony. never been there. neither have i been at students' cafe 40 meters in opposite direction. i think i need to investigate close-to-home cafes. so.
 
Looks like we're not that far from replacing CPython as the flag implementation.
 
@CatPlusPlus with?
 
Is it not possible to call a constructor to initialize values in C++
 
4:39 PM
PyPy.
 
hopefully something faaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaster!
 
I would go to the students cafe perhaps you can pick up a hot guy or girl
 
It's already faster, but it doesn't implement Py3 yet.
 
4:40 PM
@LewsTherin Some code as context could help me understand what you mean.
 
And C extension layer is still in the experimental phase.
 
PyPy is fast as hell
 
oh, how can it be faster if it is python in python?
 
because of their tracing jit
 
It's Python in RPython, actually.
It's translated into C.
 
4:40 PM
@AlfPSteinbach the interpreter is rpython, and translated by the rpython compiler to C
 
And have a powerful JIT.
 
he he i need tu reed up on it
 
The translator itself is all magic and unicorns.
 
horny corns
 
And because it's written in subset of Python, tinkering and maintenance is much easier.
 
4:42 PM
@LucDanton ideone.com/1bMsn
 
lol that doesn't make english sense
 
There's nothing to not like about PyPy.
 
at one point I wondered about using pypy for another language other than python
but I did not have time
 
@LewsTherin You can do that in C++11.
 
@LewsTherin There is such a feature, called delegating constructors, in C++11 but I don't know of a compiler that has it.
 
4:42 PM
But it has to be in init list.
D(): D(1, 2) { .. }
 
in c++11 you can say class D { int x = 1, y = 2; };
 
4
Q: Reusable constructors C++

eversorOne of the corner stones of OOP is reusing code instead of repeat it over and over. Thus, your projects shorten and get more readable. C++ gives you all the tools you need to reuse methods instead of repeating the code. Although when it comes to constructors I do not know how to reuse them. I a...

 
@JohannesSchaublitb I know @RMartin said it mmn
 
tho gcc doesn't support it yet (only clang out of the two)
 
(You can upvote me on the way out.)
 
4:44 PM
So it is not possible with current compilers great
 
It is, with a base class, see my answer to above.
 
@LewsTherin no as I said clang supports it
 
@CatPlusPlus nice one
@JohannesSchaublitb wtf is clang?
 
The C++ compiler of the future.
 
masturbation tool of some committee members :)
 
4:46 PM
Same difference.
 
hello cows
@CatPlusPlus upboats were given :)
 
he really has highlighting on all the nasty words
 
why do you say that?
 
@Johannes said "masturbation" and poof, there you were.
 
4:48 PM
lol
 
@CatPlusPlus lol, total accident :)
 
That's what she said.
3
 
lool
 
lulz
I wish that was what she said :P
3
 
lmfao, you guys are on fire.. keep it going
 
4:51 PM
lol
wtf
 
Apparently people use that in this sort of context.
Remember that Google knows everything.
 
hahah, weird
how not to cool down your CPU
 
lol the twat, might as well put it in the fridge lol
 
when we were kids my bro and me put our mobile phones into the fridge
 
I keep forgetting that you're from the future.
 
5:00 PM
because we liked the slowmo effect they had when put on in frozen mode
@CatPlusPlus it wasn't long ago...
 
lol if I was your father I would beat you senseless
 
lulz
@TonyTheLion not too difficult to go from spalte/hole to nasty words :)
 
5:25 PM
and fudge?
 
fudge???
 
If a class has multiple constructors and this class is a data member in another class, I would have to use a pointer then in the class that holds it, assuming no default constructor.
 
No, you need to initialise it in the ctor.
Well, unless pointer seems like a better idea at the time. Maybe boost::optional.
 
If I did class Club{ Member a; } and Member has more than one constructor it won't let me..unless I have a default ctor
I'd have to use a pointer...I have to learn this Boost
 
5:35 PM
Or call a proper ctor in Club ctor. ideone.com/fH3Xh
I try to avoid pointers if possible.
 
can't you indent your code? :P
so it is possible only if I call the constructor in the initializer list
 
Too lazy.
 
lol hate reading code like that
thanks, it worked
 
YIL I learned that concepts are about more than just improving the quality of error messages. They enable function overloading for groups of types.
This is quite awesome IMO.
However, today's blog post by Sutter mentions that similar functionality can be achieved with enable_if. Does anyone have any experience with that?
 
SFINAE will turn up sooner than later in generic programming.
 
5:44 PM
I'm a bit hesitant to rely on SFINAE in production code.
 
Don't think I have a simple example of my own on hand though.
 
The example mentioned by Herb explained that currently it would not possible to distinguish: std::sort(items.begin(), items.end()); and std::sort(items, predicate);. (Latter doesn't exist currently.)
 
Come to think of it, I do a lot of my SFINAE via decltype in addition to enable_if.
 
@StackedCrooked it would be possible if you for example said that every container used as items shall inherit from some special marker class
or shall specialize some special class template
etc...
but if you keep it entirely general of course there is no way
 
The way Herb named the trait he's suggesting that detection of begin and end members be used as the criterion.
Which is not overly generic tbh.
 
5:50 PM
yeah with the class template specializuation way it would be possible to pass arrays too
 
Would it be possible to have the compiler skip an overload from the overload resolution set because it T::begin() is not defined for the given type T?
 
And since such a Standard trait would provide a specialization for array types it would work okay I guess.
@StackedCrooked Yes.
 
Nice!
 
@StackedCrooked yes it is possible more or less (with some limitations like, you cannot apply Luc's "default arguments for template parameters so SFINAE works" trick then for begin)
 
template<typename T, typename = decltype( std::declval<T>().begin() )> void foo(T&&); is enough I believe although GCC can't deal with that.
@JohannesSchaublitb Oh so it's not correct?
 
5:51 PM
but if you call it like Luc just showed it works too
@LucDanton i forgot you can actually call it instead of just taking the address :)
 
@LucDanton Ah C++11 only I see.
 
@StackedCrooked Yeah, SFINAE based on expressions is a grey zone for C++03 IIRC and really not reliable.
 
even in c++11 there are unsolved problems
 
Can't always typename = decltype( ... ) our way out?
 
because in c++11 too few parts of templates are actually dependent.
it has to do with name mangling
 
5:54 PM
That does sound problematic.
 
@LucDanton and I don't know whether default template arguments are part of the signature of a template
i.e template<typename T, typename U = decltype(T())> void f(); template<typename T, typename U = decltype(T() + T())> void f(); I don't know whether that overload set is valid
 
typename = typename void_<decltype(...)>::type?
 
Concerning the std::sort problem I think however that I could be solved by defining overaloads for each std container type. E.g. void sort(std::vector<T> &, Pred pred);.
 
if they are, the ABI has to have a way to mangle specializations of them uniquely
 
@JohannesSchaublitb GCC won't accept that, so I typically add typename = void dummy parameters to distinguish the templates on arity of parameters.
 
5:56 PM
ah I see
 
@StackedCrooked That's not terribly generic.
Explicit specialization would require the same amount of work and remain extensible by user code.
 
@LucDanton Indeed, however, the number of containers in the std is very finite. So it's not that bad IMO.
 
@LucDanton for function parameters, the default arguments are not part of the functions, but of the declarations
i.e void f(int); int main() { void f(int = 0); f(); { void f(int = 1); f(); } }
i would not be surprised if for function template parameters it is the same (since they cannot be declared again at block scope, for them it would effectively just mean that default template arguments are not part of their signature).
 

« first day (357 days earlier)      last day (4607 days later) »