« first day (396 days earlier)      last day (4553 days later) » 

sbi
8:06 AM
@RMartinhoFernandes What's the audit page?
 
sbi
@RMartinhoFernandes Ah, that one. Yes, it shows the same amount, 54 less than yesterday – which is why I was asking about a recalc.
 
sbi
8:19 AM
@RMartinhoFernandes This made me remember that I had the feeling I have a serial upvoter a while ago. maybe that triggered the recalc?
 
Ah, that could be it.
Ok, new GCC installed...
Sanity checks running... Ok
Testing template aliases... Fail :(
 
@RMartinhoFernandes Still no TLS
they're doing this just to spite me
 
Testing user-defined literals... Ok :)
Seems like I need to wait a few more days, or compile a newer snapshot myself.
No, wait, the using bar = foo; syntax is supported, but only on local scope?
@Omnifarious can you compile: using a = int; int main() {}? (that's the full program)
With -Wall -Wextra -pedantic.
I get "error: extra ';'". That's just silly.
namespace { using a = int; } int main() {} doesn't compile either, but the invalid namespace { using a = int } int main() {} (notice the missing semicolon) works fine.
Damn bugs.
Well, it's better than nothing. At least I can write syntactically wrong code as a workaround.
@jalf Yeah, the concurrency part is severely lacking.
 
8:37 AM
I can live without the rest of the concurrency stuff. Most of it is fairly simple to do yourself with intrinsics or other apis, but I really really really want sane standard-library support for thread-local non-POD types
 
I've got a confusing linker problem...
 
Missing or duplicate references?
 
first I got undefined reference to _Unwind_Resume
 
I mean, there are no other kinds are there?
 
so I linked with -lgcc
 
8:42 AM
@RMartinhoFernandes Visibility issues what with LTO and ld.gold used to be a bane.
 
@IntermediateHacker Are you compiling with gcc or g++?
 
g++
now I have undefined reference to _Unwind_SjLj_Unregister
 
Also, I believe the standard library is -lstdc++.
 
Morning guys
 
@RMartinhoFernandes still getting the error.
I don't know what's the problem.
 
8:44 AM
No idea then. Now excuse me while I go grep for typedef and play with UDLs.
 
I'm reading about vtable's right now, I thought that you created one vtable for each class when the class was defined.
But according to the page I'm reading right now, it seems that the vtable is created at run-time?
"When a child class is constructed, the parent class's constructor is called before the child class's constructor is called. Each classes constructor will put the addresses of all the virtual functions it has into the v-table. In our example, when Foo is instantiated, Foobar's constructor is called first. Foobar's constructor will place the memory location of Foobar.FuncA into
 
sbi
@Als I don't know if those C++ courses by pluralsight are any good, but Kate Gregory works there, so you might want to check them out.
 
the table is constructed once and then a pointer to it placed in the class
 
The vtables are immutable.
 
Don't trust everything you read online
 
8:48 AM
Also, that page rings very loud alarm bells.
Namely "What is a virtual table in C?"
They can't even get the title right.
 
also, there's no single official way to do vtables. Implementations are allowed to do anything, as long as it works
generating the vtable at compile-time, and storing a pointer to it in the class is merely the most efficient way to do it
but yeah, without reading the full page, I'm guessing they're describing how vtables are emulated in C
 
Thanks =)
 
I agree with @jalf , i mean look at the weird way the gobject system implements vtables.
 
I know we talked about this before @jalf but is there anyone who knows who vtables work when we have multiple inheritance?
Is it possible to only have one vtable for a class C that inherits from both A and B?
Consider the following example: http://pastebin.com/Bws4sG64
 
no, of course not
 
8:59 AM
Or will it be 3 tables for class C ?
 
both A and B will have their own vtable pointers and expect different functions in, for example, slot 0
 
@ManofOneWay Remember that you can do both A* a = new C; and B* b = new C;
If you access it through a B*, it will expect to find a vtable for B.
 
C contains an A and a B object, and each of those contain a vtable pointer, which C can then override to point to a different table if it overrides any virtual functions
does that make sense?
 
@jalf http://pastebin.com/WU68L41s
There I overwrote function b in A and function d in B and kept the original function a and c.
How will C handle that?
Will it have one new vtable containing only the new b and d ?
 
There will be a vtable for A, a vtable for B, a vtable for the A part of C, and a vtable for the B part of C.
 
9:05 AM
the parent class contains the pointer to the vtable. C contains an A, and A contains a vptr
all C can do is change where that pointer points to
basically redirecting any virtual calls made through the A interface
so A and B are always going to contain separate vptrs
 
@RMartinhoFernandes Could you, by using my example, explain how the vtable(s) of C would look?
 
why don't you take a look at it in the debugger? Won't that be the clearest way to illustrate?
Instantiate an A, and note down its vptr. Then instantiate a C, and look through its internals and note values of the vptrs you find
 
Right, that's actually a better idea.
 
Anyone know why I got downvoted on this?
http://stackoverflow.com/questions/8149102/how-does-synchronized-work
 
Yes I will do that! Thanks a lot @RMartinhoFernandes @jalf I really appreciate it!
 
9:17 AM
I'm bored.
 
you have too much time on your hands ;)
 
So if we did not overwrite any virtual functions from A and B then C will point to the original A and B Vtable's?
 
Let's do virtual bases now! How do you thunk it works?
 
@ManofOneWay Yes, that would work nicely.
@LucDanton I'm not sure I can draw that ;)
 
@RMartinhoFernandes Tbh I only cared to make the pun.
 
9:26 AM
Sooo, if C would to make yet another virtual function e() then C would have a third vtable pointer?
pointing to it's own C Vtable
 
if you do that, then you have too many virtual functions. ;)
 
lol
 
@ManofOneWay That would be an option, but you can also cheat and stick it at the end of one of the existing ones. You're the compiler after all :)
 
cheat! cheat!
 
9:33 AM
@LewsTherin I found it terribly difficult to understand what your problem was. I guess the downvotes are related to that.
> I didn't think threading would be this difficult sigh.
It is difficult.
It gets even more difficult if you stick to the the low-level primitives.
Obviously, my advice is to use high-level constructs as much as possible.
 
What are high level constructs?
 
There's the Executor framework, and a bunch of specialized synchronization tools, like the countdown latch I mentioned.
 
template metaprogramming!
 
@RMartinhoFernandes ok thanks. I have to go now anyways goodbye.
 
oh, it was in the context of Java. Guess TMP doesn't make much sense then
 
9:40 AM
Joel said that there are three major hurdles in programming
assignment/sequence, recursion/iteration- and concurrency
 
What about monads?
:P
 
@RMartinhoFernandes what about them? They're used to represent concurrency and assignment/sequence at least, aren't they? So I don't think they need a special rule
 
@jalf They seem to be a hurdle even for people that crossed all the others. But they're not as "major", and I was joking.
Look at what I found:
 
@RMartinhoFernandes I've been looking at that too. Never got around to buying it (I think I was broke last time I looked at it)
might rectify that now
Herb Sutter recommended it in some C9 video too
 
mandatory "ewwww, PROLOG"
 
9:50 AM
The title scared me a little when people recommended it, but it seems to be just a case of bad naming.
 
@RMartinhoFernandes why do you mean?
 
@jalf Brings memories of "Teach Yourself Language X in 7 days".
 
This might be a silly question, but how can one separate every vtable pointer for each class?
Let's say class A has a vt-ptr to VA, and class B has a vt-ptr to VB, now class C : A, B. C will also have a vt-ptr to VC. What about name conflicts here in the C when we have 3 different vt-ptr's, what should the pointers be named?
 
@ManofOneWay But there's no name!
 
@RMartinhoFernandes ah right
 
9:52 AM
(Remember, you're the compiler you don't need no stinkin' names.)
 
oy @RMartinho
 
@ManofOneWay the vtables aren't classes, they don't have names, and they don't need to be visible to the linker
 
did I decide that it was addExpr = mulExpr *( '+' mulExpr)?
 
cpx
I want
 
cause I seem to have written addExpr = mulExpr *( '+' addExpr)
which don't seem right
 
9:53 AM
lol
 
@jalf Of course not, but the pointers to the vtables I need to store in some way
that's where my logic fucks up
 
@DeadMG It should be mulExprs on both sides.
 
yeah
 
@ManofOneWay you mean the names of the pointers stored in the class?
 
thought so
 
9:54 AM
@jalf Yes
 
they're stored in different subobjects, so there's no name collision
In your C class from before, you have this->vptr, this->A::vptr and this->B::vptr(assuming all three exist)
 
class A
{
int *vptr;
}

class B
{
int *vptr;
}

class C : A,B
{
int *vptr;
}
 
you can't access or mutate the virtual pointer from Standard code
nor should you ever, ever need to or want to
 
@ManofOneWay The compiler can simply do the moral equivalent of A* a = new C; vtable_of_A_in_C* x = reinterpret_cast<vtable_of_A_in_C*>(a)
 
9:56 AM
No need for names.
> It's a fairly steep learning curve: this is NOT a "how to program" or "how to install" software book;
This is nice.
Much more likely to be interesting.
 
cpx
lol
 
@RMartinhoFernandes ok, just ordered it. Thanks for reminding me of its existence :)
 
cpx
how good is this for C++ programmer i guess?
 
10:00 AM
@cpx it's just an image. What are we supposed to do with it?
 
cpx
right
 
I'm clicking, but I can't look!
what, fuck?
 
@DeadMG yeah.
 
10:02 AM
That's by Uncle Bob.
 
@IntermediateHacker Because we discussed genesis and his abomination behaviour
 
man
 
@DeadMG lol. :)
 
10:03 AM
I need to sort out my code
it's so full of DRYolations :(
 
I totally need to make WET a meaningful bacronym
 
cpx
I'm going pick one for now, i think i'll go with "Clean Code" by uncle bob.
 
uncle bob?
is Robert C. Martin someone's uncle?
 
Western European Time, also known as Greenwich Mean Time, the time zone used in the UK, Ireland, and Portugal, among other countries
 
cpx
hmm
 
10:06 AM
@AlfPSteinbach What about it?
> Interesting, that's how I feel about just using static - point taken though, Singleton is more complex, but I feel it leads to more thinking about design. I've seen too much code with static variables (and blocks of code) that was just horrible to simply revert to static whenever it appears to be the simplest solution. I will, however, re-evaluate my use of singletons to identify opportunities where static might just be more elegant. – Ewald 21 secs ago
 
@RMartinhoFernandes = WET
 
@RMartinhoFernandes r u WET?
 
I made someone reconsider the use of singletons!
4
 
cpx
Robert Cecil Martin, known colloquially as "Uncle Bob", is an American software consultant and author. Martin has been a software professional since 1970 and an international software consultant since 1990. In 2001, he initiated the meeting of the group that created Agile software development from Extreme Programming techniques. He is also a leading member of the Software craftsmanship movement. His videos "code casts" on Clean Code can be viewed on www.cleancoders.com. He founded Object Mentor Inc. , a consulting firm that specializes in training their clients in C++, Java, OOP, Patter...
 
I see, it's his nickname
Sohar...
Visited it last week, one of my fav places
 
10:10 AM
@RMartinhoFernandes link?
 
Took this pic in the afternoon
 
also, singletonaholics always say that. They always carefully consider whether singletons are the best option and then they decide that it is
 
:(
@jalf You killed my buzz.
 
eh, don't worry. Getting someone to reconsider it more is a step in the right direction
which is usually all you can hope for
 
10:15 AM
anyone know a good 2d game programming book?
 
@jalf I heard you converted GMan, is that right?
 
> Singletons don't lead to any thinking of design. That's practically their only purpose. – DeadMG 1 min ago
 
@RMartinhoFernandes well, he said so ;)
 
Well, I never ever had a positive response from a singletonaholic (nice word, btw) before. I'm happy it worked, even if minimally, for once.
 
5
A: Is it good programming to have lots of singleton classes in a project?

GManIf they only need to be created once, that doesn't mandate they should be singletons. If X is a singleton, it's implied there is one instance. If X has one instance, that doesn't mean it should be a singleton. Use a singleton if you require there be only one instance of the class, and that it...

the comments there, i believe
 
10:21 AM
> So then what I want then is a globally accessible instance of a certain class... a global variable. :O
2
Heh, lovely.
 
argh
I hate default-fallthrough in switch statements
 
C# got that right.
As usual, Java didn't.
 
must fix more DRYolations
 
10:42 AM
Overloading on const with exactly the same body is a DRYolation that really annoys me.
I should be able to write foo maybe_const& get() maybe_const { return the_foo; } and get both versions for free.
 
in WideC you can do that
 
I knew you were going to say that.
 
lol
well, the situation became a bit untenable when I decided to implement user-defined attributes that have a bit more kick than the ones in C++0x
so I was pretty much forced to implement perfect forwarding on *this
and by "implement" I actually mean "intend to implement" ;p
 
In C++ protected: int foo; gives access only to this->foo or to some_other_instance_of_the_base_class.foo as well?
 
@RMartinhoFernandes the latter
 
10:52 AM
Hmm. I'm doing something wrong then.
 
just like you can access other instances' private variables too
 
@jalf Ok, what I'm messing up then? ideone.com/hBHRX
 
dunno. :)
maybe I'm wrong then? Seems odd though :)
 
I believe that they have to be part of a B instance to be accessed
either the current one or a passed-in one is fine, but not any random A
 
That's still odd.
 
11:04 AM
eh, it makes sense when you think about it
if some other class C has derived from A, it might have unknown invariants on that member variable
 
Oh, right, you can always have stronger invariants.
The C# compiler produces the same error.
Damn.
(Well, not really the same error, one a bit more descriptive: "Cannot access protected member 'UserQuery.A.x' via a qualifier of type 'UserQuery.A'; the qualifier must be of type 'UserQuery.B' (or derived from it)")
 
0
Q: A version of operator<< that returns ostringstream instead of ostream

awoodlandI always thought it would be handy to be able to write: const std::string s = (std::ostringstream() << "hi" << 0).str(); This doesn't work in C++ by default because operator<< returns the ostringstream as a ostream, which obviously doesn't have the str() member. I was pleasa...

 
GCC errors suck.
 
(I think code review is the more appropriate location for that question)
 
Now, this is annoying because in the actual code, there's no way I can break a subclass's invariants: I'm accessing a member function int id() const;.
 
11:20 AM
hello, is someone here i have a small problem in C++
 
Don't keep it to yourself!
 
A.push_back(B); A is avector and B is a vector pointer
error C2664: 'void std::vector<_Ty>::push_back(_Ty &&)' : cannot convert parameter 1 from 'std::vector<_Ty> *' to 'int &&'
im new to ++ i think i have to add & or * but nothing seems to be working
im new to C ++
 
You to insert all elements from B into A?
 
what does the vector A hold?
 
@awoodland ints.
 
11:22 AM
ints true
 
@mona What do you want it to hold ?
 
push_back only adds a single element. If you want to add more, you need to use insert.
 
a vector or a pointer to vector ?
 
oh ok i should use insert
 
A.insert(B->begin(), B->end());
 
11:23 AM
@CatPlusPlus good spot on the pointer
 
worked :D
thank you guys :D
 
It doesn't work like the @Cat posted.
A.insert(A.end(), B->begin(), B->end());
 
ok thank you :)
 
Right, position. Somehow I thought it had two iterator overload.
 
11:39 AM
Happens with me lots of time , forgetting overloads signature :D
 
@LokiAstari - thanks, I'll have a think about that. I think it might be useful for other kinds of streams (e.g. Network/Compressed/File streams). I also think the syntax using a temporary stream has some "makes the intentions of the code clear" qualities to it - I'll try and come up with a compelling example
 
12:31 PM
> Sie hat ihn durch den Kakao gezogen
lol
 
WTF's that?
 
the German for "to pull someone's leg"
 
Isn't "Kakao" "chocolate"?
 
Are you pulling my leg?
 
12:36 PM
it's basically says "he pulled him through the kakao", literally translated
 
I'll Google it.
 
@TonyTheLion Wow, that sounds ridiculous.
 
lawl, that's why I lolled
 
12:54 PM
@TonyTheLion So, how's your Tetris coming along?
 
oh I haven't coded at it much lately
but I was implementing the rotations
 
sbi
@TonyTheLion Actually, that isn't wholly true. See here.
 
1:10 PM
std::bad_alloc < ouch.
 
@sbi oh thanks :) This is where I got it from
 
sbi
@TonyTheLion I'd say it's wrong. To pull someone's leg means to joke, if I'm mistaken. However, that German expression I'd use when someone speak badly about another person (which could be in that other person's presence, or even to it, but still be done for a 3rd party to witness). Of course, that could just be me. :)
 
Ok, so what the heck does "to pull someone through German chocolate" mean?
> C99 introduced hexadecimal floating point constants ("hexfloats", such as 0x1p+1).
WTF is this?
 
@sbi oh right
 
sbi
@RMartinhoFernandes "I'd use it when someone speak badly about another person (which could be in that other person's presence, or even to it, but still be done for a 3rd party to witness)"
 
1:19 PM
@RMartinhoFernandes wtf
 
@RMartinhoFernandes Really? Brilliant. That finally matches the %a printf format...
(Which in fact is also introduced only in C99.)
 
WTF would you want to use an "hexfloat" for?
 
@RMartinhoFernandes Why not? Are you some sort of decimal supremacist?
Unfortunately, the exponent is printed in decimal.
 
@RMartinhoFernandes I get this - error: expected nested-name-specifier before ‘a’, and then a cascade of other errors. Looks like it doesn't understand the syntax at all.
 
@KerrekSB What purpose does it have, other than obfuscation?
 
1:26 PM
if i have a vector<vector int> A A[0,0] will give me the first row
if I have A as vector <vector<int>> and i want the first row, how can I get that. thanks, and sorry for the simple questions but im new with pointers and C++
 
Integral hex values are useful to specify readable bit patterns (even though I'll be using 101010_b from now on :P), but floats don't have that ability.
@Omnifarious Oh, so they broke it even more in the 4 days between my snapshot and yours.
@mona The questions are no problem :) The first example doesn't look like it compiles.
Btw, are you learning from a good book?
 
@R.martinho i debug it and when i put A[0,0] i have the first row of my matrix
 
732
Q: The Definitive C++ Book Guide and List

grepsedawkUnlike many other programming languages, which are often picked up on the go from tutorials found on the Internet, few are able to quickly pick up C++ without studying a good C++ book. It is way to big and complex for doing this. In fact, it is so big and complex, that there are many bad C++ book...

 
and later on when i put A[0,1] i have the second row
 
Oh, right. It compiles. Crap.
 
1:30 PM
@RMartinhoFernandes I don't have a snapshot. :-) I have the gcc 4.6.1 as distributed by Fedora. I... avoid snapshots unless I absolutely must have a feature, or I'm working on the project.
 
, is an operator that evaluates and discards the first argument and evaluates the second.
 
but in the other example i have vector<vector int> A now i have vector<vector int>* A
 
@Omnifarious Ah, wait, then how did you compile the code with the template alias earlier?
@mona What A[0,0] does is the same as A[0], as it is the same as A[42,0], because the comma discards the first value.
Do you understand that?
 
no now i understood
 
Is that a "yes" or a "no"? I'm confused :(
 
1:35 PM
it gave me error i should be putting A[0,1]
so the answer is no
but my question was about poitners
about if i have A as a poitner matrix how can i have the value inside this matrix
because puting A[0,1] will provide an error if A is a matrix pointer
 
You shouldn't be writing A[0,1] because that's just a roundabout way of saying A[1]. It's the same thing.
 
ok
 
But regarding the pointer issue, you can just dereference it with the dereferencing operator: *.
(*A)[1] should work fine.
 
std::bad_alloc
 
thanks :)
 
1:39 PM
@RMartinhoFernandes Well, floats are stored in binary, so printing them in a way that respects the sign-exponent-mantissa decomposition but still shows the bit pattern is a nice touch...
 
@KerrekSB I can understand printing. But what about writing them in source code?
 
@RMartinhoFernandes Oh, are you talking about new literals? I thought you meant a scanf pattern or so.
Errr... maybe the same reason? You want to specify a bit pattern for the mantissa?
 
@KerrekSB What's that useful for?
 
You can think of worse ways of spending your time...
 
If you want bitflags, use the old integral ones.
 
1:42 PM
@RMartinhoFernandes "Let me get back to you on that" :-)
 
sbi
Has anyone here ever looked at en.highscore.de/cpp/boost?
 
Someone must have requested it, I imagine.
Why not post an SO question? "Legitimate uses of literal hexfloats".
 
@KerrekSB I'm working on it ;)
But I tend to take hours to write questions because I keep distracting myself, while researching for it.
@sbi Hmm, interesting. I shall look at it. If it's good, it will be a nice link to give to people that want to "learn boost".
 
@sbi i think most of us did. did u write it?
 
sbi
@Tenev No, certainly not. I just ran into it, I had never seen it.
Is it any good?
 
1:45 PM
@sbi u've never seen the boost libs O.O?
 
sbi
@RMartinhoFernandes That's what I was asking myself. Please make sure you report back here once you've looked at it.
 
std::string operator "" _s(char const* str, std::size_t)
{
    return { str };
}
I just wrote this, and it compiles!
:P
 
sbi
@Tenev We might have a slight misunderstanding here. I linked to a book about boost which I had never seen.
 
@sbi i see now
 
cpx
@RMartinhoFernandes why is the result different if i do (1, 2) and 1,2 ?
 
sbi
1:47 PM
@RMartinhoFernandes Is this one of these new-fangled user-defined literals?
 
@sbi Yes. Now I can write "blah"_s and it's a real std::string, not a bunch of chars that decay to a pointer!
 
sbi
@cpx It isn't, I bet. Please post a complete repro.
@RMartinhoFernandes That seems helpful.
 
@cpx Needs more code.
 
cpx
i'll post on ideone!
 
sbi
Anyway, I need to work. Bye.
 
1:48 PM
@RMartinhoFernandes Is this GCC4.7?
 
@KerrekSB Yes, with an 8-day old snapshot.
 
cpx
I tried on VC++ btw.
 
@RMartinhoFernandes Ugh. I'm angry at that at the moment. Made me waste a day or to, because it seems to break Boost
 
@KerrekSB Oh, what part of boost ?
 
That is, it works with standard options, but with -std=c++11 it can't compile boost.regex anymore.
 
1:50 PM
Ah, I'm not using that :P
 
(I'd be most grateful if you could confirm, I can post my test.)
 
@sbi book seems great
 
@KerrekSB Do so, and I'll test it.
 
It wouldn't even be that bad if they had finally implemented std::regex, but no...
 
@KerrekSB Do you know of a page where you can check the status of library coverage?
I can only find one with language features.
 
1:52 PM
@sbi even tho i'm against using mutex for multithreading
 
#include <iostream>

#ifndef USESTD
#  include <boost/regex.hpp>
#  define ns boost
#  warning using Boost::regex
#else
#  include <regex>
#  define ns std
#  warning using std::regex
#endif

int main(int argc, char * argv[])
{
  if (argc != 2) return 0;

  std::cout << "Regex constants: error_complexity = " << ns::regex_constants::error_complexity
            << ", error_stack = " << ns::regex_constants::error_stack << ".\n";

  std::string str(argv[1]);

  try {

  ns::regex r("\\[([0-9]+?),([0-9]+?),([0-9]+?),([0-9]+?)\\]");
This matches a top-left/bottom-right datum of the form [1,2,3,4].
@RMartinhoFernandes I only know the usual C++11 support page.
 
@KerrekSB Couldn't you have written namespace ns = boost; instead of the macros?
 
@RMartinhoFernandes Or could I?! :-)
I'm not very familiar with using. I usually avoid it.
 
@RMartinhoFernandes What code with a template alias?
 
Not sure why I pasted that branch anyway, the STD version is useless.
 
cpx
1:55 PM
@RMartinhoFernandes @sbi ideone.com/cRNFS
 
I stripped out the sexy iterator double loop, too, because std::sregex_iterator causes a linker error no less
 
@cpx Oh, that's precedence.
The second is equivalent to (b = 1), 2
 
cpx
hm
 
But if you write int b = 1, 2; you get 2.
 
Speaking of silly things, is there a GCC option to disable the warning that #warning is an extension?
 
cpx
1:57 PM
ah
 
Ugh.
regex.cpp:4:29: fatal error: boost/regex.hpp: No such file or directory
compilation terminated.
Wait, what?
 
#warning "SHUT THE FK UP GCC!"
something like that?
 
Oh, right, I'm missing -Ipath/to/boost. Damn build systems.
 
@RMartinhoFernandes You needs teh Boozt
 
cpx
I need to remember the precedence chart somehow
 
1:59 PM
Hey, the namespace thing doesn't work: error: ‘ns’ is not a namespace-name
 
simple solution
do not ever use the comma operator, as it's totally goddamn worthless
 
@DeadMG It says, "warning: #warning is an extension" D'oh.
 

« first day (396 days earlier)      last day (4553 days later) »