« first day (330 days earlier)      last day (4619 days later) » 

9:00 AM
@FredOverflow Ok no problem.
 
I have a list of objects
list <Bullets *> bullets ;
Don't I need to make an instance of it? In C# you have to....I guess because everything is an object there
 
I wish I could start using C++ again.
 
cpx
I have another question, what are principles and idioms in C++?
 
Windows Testing Foundation
 
@LewsTherin C++ uses value semantics.
If you have int i; then you have an int.
If you do std::list<T> list; then you have a list.
 
9:01 AM
Windows Testing Foundation? WTF? Hahaha
 
@LucDanton I see thanks
 
@cpx Read "Effective C++", then you'll have an initial idea.
@cpx For example, "copy and swap" is a C++ idiom.
 
@LewsTherin No you don't .
 
As is "erase remove".
 
Bullets* is just the template argument
 
9:03 AM
It creates a list of pointers
to bullet objects
?
 
Plural class names like "Bullets" don't sound like a good idea. "Bullet" is probably better.
 
Well some of my worst project experience was using AC Foundation (Andersen Consulting Foundation), which was a Smalltalk framework translated to C. We coded this thing, lots of GUI stuff in low level very much copy-code C, for Windows 3.x and OS/2, with a good deal of COBOL and SQL added. Argh.
 
@LewsTherin I know but the class itself is std::list.
 
Also, I would probably recommend std::vector<std::unique_ptr<Bullet>> over list<Bullet>, but without more information, it's hard to tell for sure.
 
cpx
134
Q: What is the copy-and-swap idiom?

GManWhat is this idiom and when should it be used? Which problems does it solve? Will the idiom change when C++0x is used? Although it's been mentioned in many places, we didn't have any singular "what is it" question and answer, so here it is. Here is a partial list of places where it was previousl...

 
9:05 AM
The copying of bugs was annoying. There were lots of bugs copied to tens of files. Slight variations in each file.
 
@FredOverflow me too. std::unique_prt and auto_ptr are a lot better
and the vector is easier to work with
 
cpx
@FredOverflow what about the principles?
 
@IntermediateHacker You can't put auto_ptrs in a container.
 
Hey all
 
\@FredOverflow you are right will change it.
@IntermediateHacker yeah I know that...but I don't get your point
I think vectors are easier as well...but not as fast?
 
9:06 AM
@cpx Not sure about that one. Where did you even get the terms?
 
@LewsTherin e.g std::vector < Bullet* > x; x.push_back(new Bullet());
 
Code doesn't have speed unless it's going somewhere!
6
 
@LewsTherin Depends on what you do. In 95% of the cases, you want a vector, not a list.
 
Vectors are better.
 
What's our vector, Victor?
 
cpx
9:07 AM
@FredOverflow I think i have heard them right here in chat, thats how i got the idea.
 
I mean if I delete an object from the list it just changes pointers or something
but a vector has to shift and reshift..can't remember the explanation
 
Invalid pointers in a vector that changes size, heh?
 
@LewsTherin You can simply swap the to-be-deleted element in the vector with the last element and then simply remove that last element. Almost as efficient as the list approach. Of course that only works if you don't care about order.
 
@FredOverflow i think the plural convention for containers came from Microsoft
 
cpx
Someone goes like "It is against the principles of C++" and i though what principles?
 
9:09 AM
@FredOverflow true true
OK I better get back to working on the proj..thanks
thanks a lot dudes
 
In computer science, a gap buffer is a dynamic array that allows efficient insertion and deletion operations clustered near the same location. Gap buffers are especially common in text editors, where most changes to the text occur at or near the current location of the cursor. The text is stored in a large buffer in two contiguous segments, with a gap between them for inserting new text. Moving the cursor involves copying text from one side of the gap to the other (sometimes copying is delayed until the next operation that changes the text). Insertion adds new text at the end of the fir...
 
@cpx The "principle of least astonishment", maybe?
 
cpx
Yes or 'least surprise'.
 
Also known as "Interfaces should be easy to use correctly and hard to use incorrectly", but that's a bit of a mouthful :)
 
@cpx Those two are not C++ specific. They're language agnostic.
 
cpx
9:12 AM
I see, we don't have interfaces in c++, do we?
 
Well, we don't have an interface keyword, but still, clients talk to classes through a well-defined interface, even without inheritance.
 
@cpx Have you considered there were interfaces even before there were languages that supported an interface keyword?
 
@FredOverflow visual c++ has interface. so generally not a good idea to use it. i think.
 
C++ doesn't need interfaces the way Java needs interfaces, because C++ can "simulate" them with full-blown multiple inheritance.
@AlfPSteinbach What are the semantics of those?
 
@cpx an interface in C++ is not much more than a convention. but there is some slight support for class interfaces. you can emulate a java interface by having all methods pure virtual, and using only virtual inheritance from the interface class.
 
9:15 AM
0
A: getting an element from a tuple

PotatoswatterADL doesn't directly apply to template-id's such as get<0>, so the compiler doesn't really get started down that path. C++11 §14.8.1/8 (in C++03, 14.8.1/6): [ Note: For simple function names, argument dependent lookup (3.4.2) applies even when the function name is not visible within the...

 
Can inherit from zero or more base interfaces.
Cannot inherit from a base class.
Can only contain public, pure virtual methods.
Cannot contain constructors, destructors, or operators.
Cannot contain static methods.
Cannot contain data members; properties are allowed.
 
@FredOverflow: Actually the solution is ludicrously simple, just surrealistically disconnected from common sense.
 
Does anyone know a free alternative to lighthouseapp.com?
 
@Potatoswatter Oh god I'm using that for my own code.
 
Morning !
Jul 26 at 14:54, by kbok
I just read that T t(x); and T t = x; are strictly equivalent. Is this true ?
 
cpx
9:17 AM
I have just read about them when I was getting introduced to inheritance in C#. Not the keyword but the classes.
 
@Potatoswatter Also make sure to mention somewhere that your quote is non-normative, someone is bought to bring up that in the comments.
 
@LucDanton: I was wrong that ADL doesn't apply to template-id's… simply that template-id's don't invoke ADL.
 
@Potatoswatter lol @ C++ stupidity
 
@kbokthe Hi. That's a long time to get an answer :)
@Potatoswatter I can't tell the difference to be honest!
 
9:18 AM
i don't quite understand that rule
@kbokthe no
 
@LucDanton Hah, didn't see it was that old. Luckily it was starred :)
@AlfPSteinbach Yep, it's a link to a discussion explaining why as an answer to @FredOverflow's question.
 
@kbokthe They are not. For example std::vector<double> numbers(10); works, but std::vector<double> numbers = 10; does not.
 
Mmmh I'm not sure I want to pollute the global namespace with a void get(struct fetchez_l_adl*); to enable ADL though.
 
Jul 26 at 15:01, by Martinho Fernandes
An example: std::vector<int> x(10); vs std::vector<int> x = 10;
I know :)
 
(Oh also I have to make that a template.)
 
9:20 AM
@LucDanton fetchez? Is that french?
 
so, regarding Fred's problem, is the answer to add a using std::get then?
 
Sounds mexican.
 
@kbokthe Lol, also vector and 10, what a coincidence :) I chose a different element type though, to avoid potential confusion.
 
then ADL should kick in?
 
9:21 AM
@AlfPSteinbach ADL doesn't need to kick in anymore if you already have using std::get.
 
@AlfPSteinbach Hey I'm already doing that. Looks like my ADL enabled stuff is ADL enabled after all.
 
@FredOverflow hm
 
I like this example because it makes it clear why it's forbidden. std::vector<double> numbers = 10; looks way too much like the initialization of the first element.
 
Also the new list constructors are implicit. Thus std::vector<double> numbers = { 10. }; works.
 
That's a sequence constructor, aren't they all implicit?
 
9:25 AM
@kbokthe except I used to make a habit of std::vector< std::vector< float > > two_dimensional( n, m )…
 
@FredOverflow error: converting to 'foo' from initializer list would use explicit constructor 'foo::foo(std::initializer_list<long long int>)
 
too late.
 
morning folks
@FredOverflow yes: struct A { A(int); explicit A(A const&); }; A a = 0; works
but A b = a; fails
 
9:42 AM
Good morning
how is C++11 handling static class variables? Do you still have to define them outside the class declaration?
 
@ManofOneWay Yes:
> A declaration is a definition unless it declares a function without specifying the function’s body (8.4), it contains the extern specifier (7.1.1) or a linkage-specification25(7.5) and neither an initializer nor a function-body, it declares a static data member in a class definition (9.2, 9.4),
> it is a class name declaration (9.1), it is an opaque-enum-declaration (7.2), it is a template-parameter (14.1), it is a parameter-declaration (8.3.5) in a function declarator that is not the declarator of a function-definition, or it is a typedef declaration (7.1.3), an alias-declaration (7.1.3), a using-declaration (7.3.3), a static_assert-declaration (Clause 7), an attribute-declaration (Clause 7), an empty-declaration (Clause 7), or a using-directive (7.3.4).
 
However static constexpr data members of literal types can be initialized in class.
 
What's the difference between const and constexpr ?
 
A world.
 
of course in C++ const can mean different things
 
9:48 AM
@ManofOneWay constexpr functions can be called at compile-time
 
@ManofOneWay const means it can't change at runtime. constexpr further means it can be determined at compile time.
 
Yeah, so it's hard to compare the two (constexpr also has a range of usages). I think it's more helpful to show what constexpr solves.
 
morning
 
code.google.com/p/c-plus/source/browse/src/constants.h <= see lines 68-75 for a constexpr binary search
wrote just for the hell of it… but it's good to know that functional programming in C++ is ever more mainstream.
 
@Potatoswatter You're writing your own preprocessor? Why?
 
9:51 AM
@FredOverflow the lulz
Maybe I'll eventually work up to a refactoring tool framework or such. Dunno. Anyway it's the probably the most advanced currently out there, at what it does.
 
Thanx guys
 
cpx
10:06 AM
Should you go for Effective C++ after you have read C++ Primer? I think I haven't read much about STL in that book though.
hm I was thinking about reading another introductory book lol.
 
@cpx Yes, Effective C++ is the best second book on C++.
 
cpx
@FredOverflow Do i need to worry about the STL before reading Effective C++?
Because all I know is how to add and remove elements from the containers and some other toy functions lol
 
@cpx it won't jump up and bite you, so no, no need to worry.
 
@cpx No, infact Scott has written a separate book on effective usage of the STL, namely "Effective STL".
 
cpx
10:19 AM
got it.
 
The tiger era is now officially over :P
lulz
it seems my presence chases everyone away :(
 
@Potatoswatter bad news :(
 
@JohannesSchaublitb ?
 
the standards committee said in bloomington meeting they want to make that stringizing a weird unicode string will not show the UCN spelling in the result string
 
@JohannesSchaublitb LOL
they actually took the time to debate this?
 
10:32 AM
yes and they said that users expect what compilers currently deliver, not what the spec says
and they want to change the spec to be in sync
 
That makes the spec a fair bit more complicated…
 
Anyway the fix, if the debated change is exactly as you said, is for me to delete the line in my stringize routine which inserts a backslash before every non-basic-source character.
However, a user-inserted backslash before a UCN is another case which produces a weird hex code, and is independent from stringizing.
So it depends exactly what they determine.
 
i suspect we need to wait for a new draft :)
 
Are you subscribed to the committee mailings?
 
10:37 AM
I've got contact to some committee members
yeah
 
Actually it was fairly natural. I started writing the code after seeing your question, but hit upon the corner case and wrote in "this is ambiguous" before later revisiting it and seeing the solution.
 
cpx
@FredOverflow How long would it take to read Effective C++ considering that you're clear about the basic concepts? :)
 
when do you plan to add later-phaser support?
or will it stay a preprocessor for always?
 
Dunno. I've spent enough time on this lately. Right now I'm still debugging it.
 
10:40 AM
ohh
 
@cpx Hard to tell... I had already programmed in C++ for several years before I read Effective C++, and almost every chapter was still in eye-opener for me.
 
Still need to get through Boost Functional, and then I'll see if performance is reasonable.
 
do you plan on making a self hosting compiler?
 
You can skim the book in a few hours, or you could take yourself several weeks to really appreciate every item.
 
10:42 AM
If this really goes anywhere, it'll be an introspective/explanatory tool first, such as for showing name resolution.
Then maybe look for some niche, like C++ to JavaScript compilation, which could be self-hosting in a sluggish sense.
In other words, not likely to go much further than a preprocessor in the near future. It's a crowded field and there are already good frontends out there.
Although, if you want to contribute to the project, I'll happily accept your checkins :vD
 
@JohannesSchaublitb : have you already read C++ templates complete guide?
 
@MrAnubis yeah
it's a good book I recommend it
 
Can i ask you a question?
though i already got the answer and thanks to R martin but want to make sure :
 
you can ask me a question. but chances are higher you get a good answer if you ask on the main site
 
can you explain me this line -> this is the case whenever the type of the name or expression preceding the qualifying operator is dependent on a template parameter, and the name that follows the operator is a template-id (in other words, a template name followed by template arguments in angle brackets). For example, in the expression

p.template Deep<N>::f()
 
10:50 AM
oh
 
Shell<T>::template In<N> , shell<T> is what a expression or type of the name ?
 
Shell<T> in that is a type. types are not expressions. that means they don't have a type or value. they are types themselfs
p in p.template ... is an expression
 
ok , then line above from book : whenever the type of the name or expression preceding the qualifying operator -> How does this line explains shell<T> ?
shell<T> is name or type ? or what is its type?
 
lol I don't understand u
 
Perhaps you could use some quotation marks to separate your own words from the book's words.
It is hard to understand.
 
10:57 AM
hmm , type of the name or expression (line from above para from book) -> shell<T> is name?
what i mean to ask is : Shell<T>::template In<N> ->the first para from book ( which i've pasted) applies to this code too?
@JohannesSchaublitb & @LucDanton : can you read my messages in the chat history : chat.stackoverflow.com/transcript/10/2011/9/10/19-20
you guyz gone?
 
@MrAnubis: anything following a -> is a member object or function. Anything preceding a :: is a type.
 
yes i understand this but that para is killer para
 
In practice, specifying template for member templates is rarely necessary, and G++ at least will help tell you when it is necessary.
So I wouldn't worry too much about memorizing these rules… the more important thing is understanding why templates are used and how they solve engineering problems.
 
@Potatoswatter : thanks , but i am very persistent idiot , unitl i don't get something which i've started i keep crying
 
Fair nuff. Simply put, if the object or type before the :: or -> depends on a template argument, and the name after the :: or -> is a member template for which you are specifying explicit arguments inside < >, then you need ::template or ->template.
If that isn't simple, it's because so many requirements have to be satisfied. It's really a corner case.
 
11:12 AM
if the object or type before -> but author says : whenever the type of the name or expression...
what does he means by type of name?
I'll kill Vandevoorde if i see him somewhere , vague theory
 
@MrAnubis Names don't have types. Expressions have types. "The type of the name" is nonsense. So ignore it.
Maybe he means the "type name" before ::. Types aren't expressions.
 
yes , @Potatoswatter : thanks for quickhelp )
 
@JohannesSchaublitb: By the way, my main problem with the preprocessor is failure to evaluate expressions for #if. Do you know of a good self-contained C++ expression evaluator? Clang is supposed to be modular, does it have a helpful component?
In particular, G++ rejects #if "hello"[2] which is a valid constant expression. Does Clang accept this?
 
@Potatoswatter I would have thought an lvalue for a static storage duration object would not have been a constant expression. Did something change for C++11?
i.e. I'm accustomed to prvalue constant expressions only.
 
@LucDanton Actually, it depends whether string literals are constexpr and not merely const — an assertion I didn't check. It only makes sense that they would be in the context of user-defined literals, but let me see…
 
11:25 AM
@Potatoswatter You're correct that if nothing has changed then they would clash with user-defined literals...
On the other hand, user-defined literals don't have to be constexpr either.
 
Hmm, the exact wording is "a glvalue of literal type that refers to a non-volatile object defined with constexpr". A string literal has no definition, thus it is not defined with constexpr.
 
0
Q: C++ templates misconception ( A black voodo from book 0_o )

Mr.AnubisI am reading this specific topic in Templates complete guide : 9.3.3 Dependent Names of Templates ... some damn code template<typename T, int N> class Weird { public: void case1(Shell<T>::template In<N>::template Deep<N>* p) { p->template Deep<N&g...

 
@TonyTheTiger Shell<T> is not a dependent name. In would be a dependent name.
 
@LucDanton Rather than go to the Standard initially, I just tried an experiment with G++ and it accepted it. How's this for an abomination? ideone.com/oH8F6
std::cout << char( sizeof( char[ "hello"[1] ] ) ) << '\n';
 
I had a good chuckle.
 
11:34 AM
@TonyTheTiger: Good thing you skipped Tony the Snow Leopard.
 
@LucDanton so my answer is wrong then?
 
@TonyTheLion I believe that e.g. "Shell<T> is a type and In is the dependent name of one of its members" would be more accurate.
 
@LucDanton so why did @jalf repeat what I said in the comments on my answer?
 
I take it he's commenting on what Mr.Anubis is doing rather than commenting on your answer directly.
But I didn't check whether what I've said is correct with the Standard either -- it's a good thing to be skeptical :)
 
oh I see
 
11:39 AM
@Potatoswatter oh, hmm
 
@LucDanton yep
 
you need to break it down to operators that are valid on simple ints
i think that is not too much
 
oh...
 
doesn't need to support all the fancy things like constexpr
dunno about anything. clang is a little large
 
@JohannesSchaublitb : please please can you answer to my question before it gets closed ? stackoverflow.com/questions/7377892/…
@jalf : thanks for comments
 
11:41 AM
@MrAnubis you mean the question that, by your own words, you already know the answer to?
 
@JohannesSchaublitb Well, the intent is that replacing all the identifiers with 0 simplifies everything greatly. Of course I don't need to support such to make Boost Functional preprocess.
 
yes
 
But if I'm going to write something myself, I prefer to do it in 10 lines or do it right :vP
 
Did you also learn maths by asking "what is 2+2" five thousand times?
 
Also, the intent of LLVM was to be modular… long ago.
 
11:42 AM
there are some algorithms to parse expressions with different precedence levels
don't remember off head though
 
I'm confused :P
 
@jalf no
i know its 4
 
lol @Potatoswatter
llvm is a bit unwieldy :(
 
@MrAnubis so why do you think it would work here? Ask about the specific thing that you want to know
not the much broader question you already have the answer to
What is it about the answer you have that confuses you?
 
11:44 AM
@jalf :just the question : what is Shell<T> , a name or expression
 
@MrAnubis no
 
>> Whatever you do, do not repeat the exact same question twice. If you got no reply the first time, its either because none of us know an answer, or you didn't give us enough information. Change your question, and provide more supporting information, before asking again. <<
 
> sorry, unimplemented: cannot expand 'Args ...' into a fixed-length argument list
 
you already got an answer to that
 
Snapshots come and go but this bug still is here :(
 
11:45 AM
So what about the answer confuses you?
Let's start over. What was the answer that you got?
 
what confuses me is i know Shell<T> is type , but book talks about name and expressioin
 
@MrAnubis Then perhaps you should ask that
 
@jalf : now can you please please answer the question in SO to my question?
 
@MrAnubis Yes. "please read the answer you already got"
 
11:47 AM
@MrAnubis ...
"Shell<T>" is a name
 
@MrAnubis WHICH ANSWER DID YOU GET BEFORE?
 
and the name names a type
so the book says "the type of the name"
...
 
@MrAnubis your question isn't asking what the difference is between name and expression, it's asking about shell<T>
 
What you're saying is basically "I asked this question and got an answer to it. I didn't understand the answer, but I won't tell you what the answer was. Please explain the answer to me even though I haven't told you what it was"
If you don't understand the answer you got, why don't you just say "here is the answer I got, I don't this part of it, can anyone explain it?"
 
11:49 AM
Ok i apologize for question and mistake , but i am happy i am confirmed with answer
 
I think he is like "I may have found a bug in the book but I need someone to verify that I indeed found a bug. The problem is, this book says that Shell<T> is an expression."
 
No one is asking you to apologize. We're just asking you to ask questions that are related to what you want to learn
 
ok
 
The answer to "is this a name or an expression" is obviously either "it is a name" or "it is an expression". If the answer you get is "it is a name", and you don't understand why, then your next question should not be "is it a name or an expression", but "why is it a name?"
 
11:53 AM
for example (p + 0)-> ... the postfix expression is not a name, but an expression. in p-> ..., the postfix expression is both a name and an expression. and in Shell<T>::... it is not an expression but a name
finally in decltype(Shell<T>())::... it is neither a name nor an expression. but the book is not about c++11 so it doesn't handle this case
 
cpx
Hi
 
Looks like there's the critical mass of regulars to ask what has been bugging me this morning (and which I've discussed with Potatoswatter earlier today): we already have the convention when turning a move-only type into a copiable, shared type to name the new type shared_*, as is the case with std::future and std::shared_future.
What would be the converse convention when writing a move-only type with roughly the same functionality as a copyable type?
 
11:59 AM
Damn you. I wanted to ask something. I'll wait. ;)
 

« first day (330 days earlier)      last day (4619 days later) »