« first day (388 days earlier)      last day (4561 days later) » 

9:01 AM
hi
 
sbi
lo
 
Toto, I wish it was Friday :'(
 
sbi
TGIT.
 
Ha ha that's still ages away!
 
sbi
What are these people seeing?
 
9:11 AM
Those expressions are just terrible
 
sbi
I think that's the point.
 
I need to program something to get familiar again with the STL, any ideas?
 
They're seeing Elder Things?
 
sbi
@RMartinhoFernandes This seems to ring a bell, but I can't place it.
Ah, Potter, right?
 
@sbi Yes, but they still made a terrible job of it.. but 2 maybe
@sbi That's Elder wand
 
sbi
9:13 AM
@LewsTherin I understand that these pictures are genuine.
 
@sbi Lovecraft.
 
sbi
@Nils You are looking for something where algorithms are applied to sequences of data. I'm sure you can think of applications of this principle.
@RMartinhoFernandes Ah. I never read Lovecraft. Maybe I should. I keep running into references.
 
I'm heading to college. Later
 
I'm also looking for some advanced reading material on the STL.
 
sbi
9:30 AM
@Nils For the philosophy, there's Austern's classic (if somewhat dated) Generic Programming and the STL.
For an introduction into the standard library there's Josuttis' The C++ Standard Library.
The best second STL book I know is Meyers' Effective STL.
afk
 
ah I didn't know that there is a meyers book about the stl
thx
 
9:43 AM
does anyone use exceptions or can I just skip them?
 
@Nils they're most important
the trouble is, about the only useful standard exception is std::runtime_error
 
humm so far I ignored exceptions in C++
 
Hi
 
sbi
@Nils The standard library and the runtime system (new, dynamic_cast) use exceptions. You can most certainly not skip them. In fact, you need to write your code in a way that nothing breaks in face of an exception thrown from almost any line.
 
Does anyone know where (in which namespace) I can find _1 for std::bind using VC10 ?
 
9:47 AM
Reading More Effective C++. I have grown to appreciate at least some uses of most C++ features, but I still don't buy in on exceptions.
meh
 
and what @sbi says here, means that any C++ code should better be prepared to exit from a function at any point, hence multiple returns in C++ is not as troublesome as in C
in C multiple returns generally add problems, e.g. a return is inserted before cleanup. in C++ multiple returns generally bring clarity, avoiding unnatural code paths just to end up at a single return at end. so the language differences mean very different styles, "SESE" versus "SEME" as they were called when that stuff was debated
4
.
well i would really appreciate ideas for getting g++ std::wcout to produce UTF-8 output in Windows -- without reimplementing the whole shebang
main problem is that wcout is not required to use codecvt facet of locale, and with g++ does not
ah, I think I'm possibly closing in on a solution, namely __gnu_cxx::stdio_filebuf
 
10:02 AM
Do you think anyone even put attention on your chat?
Why don't you ask it on Stack Overflow?
 
why should i?
 
@Nils part of the reason for that could be that 32 bit Windows has such an inefficient ABI for exceptions. People concerned with performance tend to get a nasty chock when benchmark it
@AlfPSteinbach no clue here. I've always stayed far away from the implementation of iostreams
 
I actually find what @AlfPSteinbach says interesting. I just don't know enough about codecvt to be of any use in the conversation.
 
@jalf have you done that, or can you provide any reference to an honest benchmark? the standardization committee benchmarked, you can check out the performance paper.
 
@AlfPSteinbach I've seen several benchmarks yeah, they generally show something like 8-15% slowdown, which is a lot just for glorified error handling. The problem is that SEH requires unwinding information to be written into the stack frames, so even when an exception is not thrown, you pay a noticeable cost. And when it is thrown, the stack has to be unwound with the same mechanism which is even slower
Linux and Win64 uses a table-based approach which is basically free in terms of runtime speed
 
10:08 AM
@jalf yes, you can have that with g++, but not afaik with visual c++
here's the old performance paper
 
@AlfPSteinbach afaik, they changed it with VC++ for 64-bit windows
it uses a sane table-based approach
 
good :-)
 
agreed
 
10:25 AM
Hi guys
Anyone knows how virtual method tables work?
 
magic?
 
the compiler generates an array of pointers for every class type
Each object stores a pointer to the beginning of such an array
specifically, to the array that matches its types
 
an array of vtables?
one vtable for each class?
 
no, an array of pointers
function pointers, basically
one vtable per class
and a vtable is a list of pointers to functions
and the class contains a pointer to a vtable
 
10:28 AM
yes okey
great
so what happens if you have a class that inherits from 2 classes?
or to start with, 1 class
will that object then have 2 pointers? one to each vtable?
 
then things get hairy ;)
if you derive from one class, you just overwrite its vptr
so you make it point to your vtable instead of its own
that way, all the parent class's virtual functions now point to your overridden versions
tbh not sure how multiple inheritance is handled
 
great thanks!
shouldn't multiple inheritance just be that if you have a baseclasses A and B and C : A,B.
And A contains virtual function foo() and B virtual function bar() and C overrides only foo(), C's Vtable should consist of
C::foo()
B::bar()
 
10:53 AM
@ManofOneWay multiple ordinary inheritance is simple but tedious. since C is an A, part of a C object's memory layout must be identical to A. And ditto for B. And this means that a C object does have at least two vtable pointers. One for the A sub-object, and one for the B sub-object. You might try to get hold of Lippman's "Inside the C++ Object Model". I haven't read it but it's recommended by people (even if it's old).
 
If you care the itanium ABI document is a good read too, because it's used as the basis of the ABI on quite a lot of other platforms now too
 
sbi
@AlfPSteinbach Wouldn't std::wcout simply emit whatever is "the natural wide character format" on the platform? And wouldn't you have to use a special stream for emitting UTF-8?
When we once needed to write UTF-8 to files, we used narrow streams, passing them std::string(utf8str.begin(), utf8str.end()) for output.
 
@AlfPSteinbach So you don't have just one vtable pointer in C where that vtable contains (possibly) A and (possibly) B and C virtual functions?
 
sbi
Do you know Hansel & Gretel? A simple story, right? Well, as so often in life, it's more complicated than you thought.
 
@sbi that's what I thought once. but i learned the hard way that std::wcout's job is to convert from wchar_t down to char sequence... and in Windows, by default that apparently means to Windows ANSI Western, no matter what codepage is active. with visual c++ i could just imbue a locale constructed with a conversion facet, but the standard only guarantees that it's used for file stream buffers. happily now confirmed that __gnu_cxx::stdio_filebuf honers and uses that facet. :-)
 
11:00 AM
@ManofOneWay - the trick is that A and B need to find virtual overrides provided by C
 
@awoodland So what you are saying is that it could be problems when we are downcasting an instance of C to B or A?
 
sbi
@AlfPSteinbach Ok, so it uses "the natural console character format" (which is whatever codepage your system is set on Windows, and UTF-8 in the Linux consoles I have encountered).
 
@sbi The thing I'm doing yields usage code like this:
#include <progrock/cppx/u/adapted_iostream.h>
using namespace std;
namespace u = progrock::cppx::u;

int main()
{
    u::out << U( "Hello, world!" ) << endl;
    u::out << U( "2+2 = " ) << 2 + 2 << endl;
    u::out << U( "Blåbærsyltetøy! кошка 日本国!" ) << endl;
}
Which presents those Russian and Chinese characters correctly in Windows console, and produces UTF-8 when stream is redirected or piped. :-)
 
@ManofOneWay - what I'm saying is that after downcasting (or in a member function of A or B) they still need to be able to find the virtual member functions that C introduces, even though they know nothing of C
 
@sbi no, as I said, the narrow text result isn't dependent on codepage. it seems to always be Windows ANSI Western. because it's hardcoded in the runtime library and also to fit the compiler's hardcoding of (compiled) string literals
 
11:04 AM
@awoodland But if an instance of C, c, has a pointer to a vtable containing which functions it will call, and c is downcasted to a pointer of B, b, will not b still contain the pointer to c's vtable?
Is that not a possible way of doing it?
 
sbi
@AlfPSteinbach I seriously much doubt the console is ANSI Western when you are using, say, and Eastern European codepage. ICBWT.
 
@sbi I didn't say that.
 
Since that b will point to c and the first thing in c will be a pointer to a vtable, and that vtable is C Vtable.
so b->vtable_ptr will be the same as c->vtable_ptr
 
namespace u = progrock::cppx::u; <- assignment to namespace? 0_o, typo?
new in C++11?
 
@sbi but it is interesting in a way. narrow string literals in the code can be almost any encoding, because neither g++ nor visual c++ checks for validity. the bytes are just passed through. however, wide string literals have to be translated.
@MrAnubis no it's been there since C++98. it just a namespace alias.
 
11:10 AM
@AlfPSteinbach new to me , thanks
 
you're welcome
 
Hi again
I got a job!
 
Congratulations!
 
@AlfPSteinbach Thank you :D
 
What will you be doing?
 
11:29 AM
Working with Oracle and Java to create Android apps. I'm confused about the Oracle part but I'll see I guess
It's an intern job, so hopefully they won't leave me alone entirely
 
@AlfPSteinbach oh, that's pretty neat
 
12:23 PM
humm I want something to code involving the stl
any ideas
 
Make a game. I used it a lot
Or write some algorithm, MST.
 
MST?
 
minimum spanning tree
 
last thing i did was gradient descent, but didn't use stl for that
 
Don't know what that is...
 
12:30 PM
Gradient descent is a first-order optimization algorithm. To find a local minimum of a function using gradient descent, one takes steps proportional to the negative of the gradient (or of the approximate gradient) of the function at the current point. If instead one takes steps proportional to the positive of the gradient, one approaches a local maximum of that function; the procedure is then known as gradient ascent. Gradient descent is also known as steepest descent, or the method of steepest descent. When known as the latter, gradient descent should not be confused with the method of ...
 
Is EffectiveSTL by Scott Meyers free? uml.org.cn/c++/pdf/EffectiveSTL.pdf
 
@Nils Wow, I would never be able to do that...
 
sbi
@ManofOneWay No, it's not. (That doesn't stop the Chinese, though.)
 
@Nils - you could probably do a simplex method quite nicely using standard library stuff from <algorithm> to express the mechanics of it
 
@ManofOneWay thx
 
sbi
12:43 PM
@Man & @Nils: That version obviously lacks the red/blue coloring of the code which Scott uses to emphasize.
 
12:59 PM
What was the code review stack site again?
oh, it's apparently only for small snippets
 
Oh, bronze badge.
 
I have mixed feelings about codereview.stackexchange.com
 
it seems short on experts from when I'd looked at it. it also lacks local style guidelines which seem to be 50% or more of a lot of real world code reviews
 
It's not really a style review site.
 
1:10 PM
I'll just test the waters by posting about the little program I posted above. :-)
 
1:53 PM
0
Q: Feedback on scheme for source code level portable C++ Unicode literals

Alf P. SteinbachWindows console windows do unfortunately not support stream i/o of international characters. E.g., in Windows 7 you can still do chcp 65001 (sets the active code page to UTF-8), type more, and get a crash… This means that it's practically impossible for a novice to write a "Hello, world!...

 
meh where do I put inline impl or header?
 
@Nils what?
 
if you have a method and want to tell the compiler that it can inline it
where do you need to write inline
in the declaration or implemenation?
 
Compiler will disregard your opinion on the matter, anyway. If you don't use LTO/LTCG, then for inlining functions must be fully defined in all TUs, though.
 
LTO/LTCG?
so where now?
 
2:01 PM
Link-Time Optimisation (GCC, Clang) / Link-Time Code Generation (MSVC).
 
@Nils I think I understand the question now. The answer is header. And you can't put the implementation in a separately compiled file: you need to put that also in the header.
 
ah.. ok
thx
 
2:23 PM
@AlfPSteinbach It's a shame that you reach a much smaller audience of Code Review than on SO.
 
2:48 PM
const int height, width;
is in this case width also const?
 
I believe the correct answer is "don't write code like that"
 
why not?
if it is well defined
 
@Nils because you're not sure what it means, and the person reading the code very likely isn't sure what it means either
 
@Nils because your main object is to communicate to your later self and other programmers, not to communicate to the compiler. making the compiler understand is the smallest part. that could in principle be done in assembly language.
 
You're not writing code just for the compiler to read. You're writing it primarily for people to read.
 
2:53 PM
@awoodland How would it carry that. People would have to have IDs to which "style" they use (meaning their company). Then you'd have to make that anonymous, because I doubt a company wants everyone knowing their coding standards.
 
yes sure, right now I'm writing code for myself
 
Otherwise, it'll be a bunch of. Oh you're company coding style stinks, etc.
 
and I would like to know what it does
 
and you are not sure what it means either
and if we look it up and tell you, then you'll likely have forgotten by the time you run the code in the debugger
 
yes that's why i ask ;)
 
2:54 PM
and then you'll have to look it up again
 
jajajajaja
:P
 
I'm guessing that only the first variable is const, but I haven't looked it up, because I just avoid code like that
I mentally divide C++ into two sections: the part that I try to make sure I understand, and the part I just avoid because I'm better off never using it.
and I put stuff like this in the second half
I could look it up, but it's simpler and easier to just write code I can read
 
They'll be both const.
 
@CatPlusPlus thx can you explain me why?
 
const is part of the type specifier, like unsigned.
 
3:04 PM
:)
 
Als
Is puppy @DeadMG nominating himself again for mod this year? :P
 
Does the have a proper mod?
 
3:19 PM
Tags don't have mods.
 
Als
@awoodland, is up for being a mod.
 
@CatPlusPlus Yeah, but I saw several mods last year arguing that there should be a mod with experience for each of the top tags.
 
Als
@Xaade: Yes
thats true
its a need for sure
 
@Als - I figured I'd give it a shot although I'm not sure I'll even get past the nominations phase
 
Als
@awoodland: Yup. i know but well its always worth trying :)
@Xaade: An example that shows the need for mods with experience on tags.
0
Q: what does this snippet mean in linux c

Macroidealbuddies, what do this two snippet code mean here? 1. #define HTTPH(a, b, c, d, e, f, g) char b[] = "*" a ":"; this "*" a ":" 2. void function(char *p) { (void)p; } Thanx alot

I don't see a reason why this was closed.
How is it Not a Real Question?
 
3:28 PM
it's two real questions, which are entirely different
 
Als
@cHao: And both of them fairly valid. Are all Questions that ask more than 1 Question closed as Not real Questions?
 
not that i agree it needed closing
 
@cHao Makes it harder to research.
 
but two entirely different questions should be asked as two different questions
 
However, the mods should have requested the user split them, or possibly split it themselves.
 
Als
3:30 PM
In my SO exp, I don't think Q's asking more than 1 Q are closed.
 
It would be nice to have a question split option.
That way the poster gets credit for each question.
Or a good part of the question doesn't suffer downvotes because of a bad part.
 
two questions that are related, no. but these two aren't related other than that both ask "what does this do"?
 
Als
Both of those Q's are valid ones is what matters and just being closed as not real Q is not the way
 
they don't even use the same code snippet
 
@Als Only if they are closely related. (What does this do, and how does it do it).
 
Als
3:32 PM
@Xaade: So next time I see 2 questions asked in one Q i vote for close?
 
Not (What's the square root of X^3, and What's the scientific name for a zebra).
 
Als
How many Qs are closed this way.
 
@Als rather few, really
it's not often a user asks two entirely separate questions at once
 
@Als I think I just said, that it would be appropriate to have the poster split the question themselves. To handle cases where the poster doesn't, mods should have a question split ability.
 
Als
@Xaade: And I think My question was, how appropriate is the closing of the Q as Not a real Q
 
3:35 PM
@Als not very, IMO. but i can definitely see some reasoning behind it.
and we don't have a reason that means "one question per question, please"
NARQ is the best fit we have
 
Als
@cHao: So the q is being closed for 1 question per question but is said as Not a real Q. That is little stupid because by saying second you mean its not a real Q but by first you mean oh no you got 2 valid Q's there so we don't allow it.
 
i have class template with sig : template<template<typename T> class G> class foo; , is there any way to access T inside class scope of foo ?
 
@MrAnubis - I'm not quite sure I follow.
the whole point of that syntax is that you get a template G without needing to fix it to a specific T
 
@Als look at the description of the reason. "This question is...overly broad...". like i said, there's no reason that specifically means "one question per question"
 
3:41 PM
@awoodland you're right but I was curious to know is there any way?
 
@MrAnubis - normally I'd write template<template<typename> class G> anyway
 
@Als if you want more clarification, take it up on meta. i'll upvote, particularly considering i don't particularly agree with the closing
 
@MrAnubis - if you care about specific Ts you can use a partial specialisation
(I think)
 
@awoodland any small example??
 
@MrAnubis - hang on
@MrAnubis - I'm struggling to do something useful and legal that isn't a complete specialisation
 
3:48 PM
@awoodland no problem , anyways thanks for help :)
 
4:00 PM
one more thing , what is this new signature : friend auto operator+(Vector2<T> a, Vector2<U> b) -> Vector2<decltype(a.m_data[0] + b.m_data[0])> {}
 
@MrAnubis the auto is a placeholder in that which gets replaced with the bit after the ->
basically it allows to write the return type after the arguments
 
this belongs to 98 or 11 ? or both?
 
which means you can use decltype with the arguments (which don't exist where the return type normally gets written)
it's C++11
 
Als
@cHao: i guess its pointless to take those on meta, its not really user friendly the meta..its mod friendly
 
@MrAnubis - it mirrors the way you write the return type for lambdas too
and fits with the new meaning of auto
without breaking any existing code
 
4:07 PM
@awoodland aah , thanks again :)
 
@MrAnubis - the return type depends on what the types of the two inputs are
so the result of T+U
which can have a promotion
 
@awoodland wow , some awesome thing to know today :)
 
the C++98 way of handling promotions like that was really tedious
you basically ended up with a promotion_traits class and loads of specialisations
but that wold for example make (for example) BigInt support tedious, whereas this syntax makes it all automagic in the one place
 
If you want to be able to switch between float and double, it does not make sense to use templates for this.
I think best option is something like typedef scalar float;
 
@Nils - it depends slightly on what exactly you're writing if that's appropriate.
 
4:13 PM
a numerical algo for floating point
which either works with single or double precision
 
If that lives in a library though then you end up shipping a library called libmyalgo_float and libmyalgo_double and libmyalgo_complex and libmyalgo_gmp that users are required to link against as appropriate which can be more tedious than just doing it with templates through and through
 
humm
writing a class template for floating point and complex values is a major headache I guess..
 
@Nils - I think there's a cutoff point where it becomes worth while and that for me is derived from the number of types I care about and the number of applications that care about the library. What I've ended up doing in the past is a combination - in the libraries things are generic, but in the applications there is a single typedef.
(with C++11 that becomes very nice because you can suppress the instantiation of common templates and explicitly instantiate them in a pre-built library whilst still allowing for funky types)
extern template was the first C++11 feature I used in anger too - it sped up builds on supporting compilers without breaking anything else at all
 
@Als I'm sorry, RedvsBlue.com has my brain permanently attach the phrase "The META" to a very evil AI possessed power-suit-enhanced bastard.
 
4:30 PM
std::vector<float> myVec(640*480, 0)
 
0
Q: Need a better close reason for inappropriate format questions

XaadeNaRQ sounds ridiculous to an outsider when applied to a question that's not in appropriate format. Like so: what does this snippet mean in linux c Two questions there, but the NaRQ description makes us literally sound retarded. "Difficult to tell... cannot be reasonably answered... " I think i...

 
myVec[x+y*640]
is that correct to access 2d data in a linear array? or does it need to be x + y*(width-1) ?
I'm slightly confused
 
@Xaade - have a vote because you have a point, but I don't think the "literally retarded" phrase will go down well
 
@awoodland "literally sound inept to explain ourselves". Changed.
 
 
2 hours later…
7:00 PM
Lol someone mailed me a CGI/Python question.
 
mailed as in "via the postman" or emailed?
 
Via email. What's the other thing?
 
@CatPlusPlus - just wondered. I've had 419 scammers write to me via the legacy mail system before now
 
Als
7:16 PM
Folks upvote my comment on this Question, so it becomes visible:
11
Q: Why should the implementation and the declaration of a template class be in the same header file?

Haiyuan ZhangWhy should the implementation and the declaration of a template class be in the same header file? Could any of you explain it by example?

 
And it's an HTML email, too.
Written in MS Word, no less.
 
@Als - there already was a C++ faq one
 
Als
@CatPlusPlus: psst ...
3 mins ago, by Als
Folks upvote my comment on this Question, so it becomes visible:
 
hang on
 
Als
@awoodland: Oh is it?
 
7:21 PM
25
Q: Why can templates only be implemented in the header file?

MainIDQuote from The C++ standard library: a tutorial and handbook: The only portable way of using templates at the moment is to implement them in header files by using inline functions. Why is this?

I almost vote-closed the one you linked to as a dupe of that
 
Als
@awoodland: Ah okay
 
I wonder if I'm already famous or something.
 
Als
Sorry i missed it, I will remove the tag on one i marked faq
 
I wasn't sure which I liked the wording of better
 
Als
@awoodland:The one I marked was just providing an link
hence i stated if theres anything better
 
7:24 PM
Huh, Enigmail apparently screwed up the signature on my reply.
 
Als
ah..need to go ZzZz..
 
neither of them mention linker errors though which seems to be how dupes of this get asked
 
Als
have a good day folks.
@awoodland: Yesh neither of them actually quotes standards and explains it is okay to separate declaration and definition in header and cpp as long the definition is visible within the same TU.
So probably, there could be a better match
If someone decides to write an new answer or something to address this in better way, this might be useful.
3
A: private template functions

AlsWhen a function template is used in a way that triggers its instantiation, a compiler(at some point) needs to see that template's definition. And that is the reason, templates are usually implemented inside a header file using inline finctions. So as long as the above rules gets followed it is s...

The Standard Quote....
 
@Als Presumably that looks different in C++11 now that export template is deprecated though
 
It doesn't say anything about explicit instantiation.
The answer, that is.
 
7:33 PM
14.7.2.4 is wildly different though now
 
7:56 PM
Oh, hey, Firefox 8.
 
Another major Firefox version???
 
They're using 6-week release cycle.
Since 5.
 

« first day (388 days earlier)      last day (4561 days later) »