« first day (258 days earlier)      last day (4695 days later) » 

10:01 AM
I'm so proud of my Dice class.
 
What does it do?
 
@CatPlusPlus Just don't instantiate your Dice class outside of Las Vegas ;-)
 
Take a guess.
 
10:02 AM
I remember having written a class for generating random values from D&D dice specification
like "2d10+4"
that was awesome
 
Who would want to play D&D on a computer? :)
 
We use that, for damage rolls and stuff.
 
@FredOverflow Actually Baldur's Gate was very good
Well maybe it's a matter of taste anyway
 
Aren't those kinds of games primarily about imagining things?
 
True
 
10:04 AM
And rolling dice.
 
D&D has a quite bit of mechanics.
 
The video games just reuse the battle mechanics and the background.
 
Playing Pen & Paper RPGs on a computer seems as pointless as watching "The Neverending Story" on DVD instead of reading the book.
 
The book never ends, man.
 
3
Q: directory_iterator - make a copy to "rewind"?

DefaultSo I wrote a small program to try out Boost Filesystem. My program will write how many files there is in the current path and then the file names. Here's my program: #include <iostream> #include <boost/filesystem.hpp> using namespace boost::filesystem; int main(){ directory_ite...

 
10:06 AM
@CatPlusPlus Are you scared of infinity? :)
 
someone mind taking a look at that question?
 
She's big, man.
 
@FredOverflow This is quite far from being pen and paper RPG
 
That should be scary.
 
@Default Is directory_iterator a forward iterator or an input iterator?
 
10:07 AM
@FredOverflow uhm... sry.. don't know..
but if you look at the linked question it might say
 
If it's an input iterator, you can't make copies.
 
It's.. well.. video game RPG I guess
 
@FredOverflow so why does it work 1 time?
I haven't modified the queue or anything.
 
I don't know. UB maybe? :)
 
oh. ok
To me, an iterator has a pointer to an object, it's value and to the next value
simplified.
 
10:09 AM
No no no. Iterators are way more diverse :)
 
that's why I don't get why I can't make a copy of it.
 
Random access iterators are like pointers. The rest is more restricted.
 
@FredOverflow yeah, that's what I don't understand I guess :)
 
It's a single pass traversal iterator. :P
 
Then read a C++ book.
 
10:09 AM
so, should I look up input iterator and how they work?
 
Boost, not even once.
 
@FredOverflow mind giving an answer about what we spoke of so that I can accept it? :) I don't like having unanswered questions lying around
 
I don't know directory_iterator, so I do not feel qualified to give an answer.
> Iterators are in fact not a single concept, but six concepts that form a hierarchy: some of them define only a very restricted set of operations, while others define additional functionality. The five concepts that are actually used by algorithms are Input Iterator, Output Iterator, Forward Iterator, Bidirectional Iterator, and Random Access Iterator.
 
thanks @FredOverflow :)
reading
 
By the way, that link describes the STL, but it should equally well apply to the standard C++ library. (Not sure about that Trivial Iterator, though. Never heard of it before.)
 
10:17 AM
@kbok a professor at my university wrote an entire programming language just for generating random values (and computing distributions) from D&D-style dice specifications.
 
lol?
seems a bit like overkill...
 
A programming language called "Troll"? :)
 
Well, he likes boardgames and rpgs, as well as programming language design, so why not combine the two? :p
 
> There is now a web interface for Troll.
Mystery solved.
 
10:19 AM
yeah, dunno what the T is for, but "roll" probably isn't a coincidence, for a language designed to simulate dice rolls ;)
 
I expected output 100d6 to produce a nice bell curve, but the horizontal scale is way too small :(
 
@jalf Well, the T is probably there for style.
 
Or maybe "T" stands for "Troll"? :)
 
@FredOverflow I guess that Boost tries to adhere to the STL..
 
10:23 AM
Yes, as discussed in the duplicate:
> boost::single_pass_traversal_tag [...] is the equivalent (in boost terminology) of the Input Iterator in the STL
 
oh well, I guess I'll have to live with a no-answer question then sob
switching subjects, just got invited to Google+
 
Oh not that again.
 
@MartinhoFernandes but it's the new cool thing!
 
exactly. the new cool thing!
 
10:28 AM
But honestly, who needs another facebook?
 
So? I'm not cool, and like old stuff. Probably one is related to the other.
 
And who needed facebook to begin with?
 
google aims for world domination!
facebook stands in their way
 
Oh, so now facebook is the good guy? :)
 
@reko_t Nah, they just want to make boatloads of money and have CoD:MW2 tournaments.
 
10:29 AM
@MartinhoFernandes of course you are :) but I'm cooler since I have Google+
 
When will we see Google++?
 
@FredOverflow that would be cool :)
@FredOverflow I think there are a lot of people who would like a new facebook. Unfortunately it is a big company now trying to fill that place but I don't mind some competition on that field
I know we spoke of it here a cople of days ago (was it @tomalak who didn't want searches incorporated in their social media? or sharing with friends?).
 
He wasn't alone in that matter.
 
Now all they need to do is add a hellish multiple-inheritance model for your social circles, and they can call it Google++.
 
haha
 
10:36 AM
He forgot about templates.
 
What would that be like? You can have template friends, and instantiate them for different parameters?
Sounds interesting.
Friend<Female,Hot,Horny>
 
You would have to think of your friends as objects
 
I've already taken care of that part.
 
and try to model it based on a real world
:)
@MartinhoFernandes can you iterate over those friends?
 
You all know that friends can touch your private parts, right?
7
 
10:41 AM
@MartinhoFernandes just remember he spoke of it passionately :)
@FredOverflow hahaha
 
lol
 
Lounge<C++, Hot, Horny>
 
11:13 AM
8
Q: Uniform initialization of references

evnuI am currently trying to understand the new uniform initialization of C++0x. Unfortunately, I stumpled over using uniform initialization of references. Example: int main() { int a; int &ref{a}; } This example works fine: % LANG=C g++ uniform_init_of_ref.cpp -std=c++0x -o uni -Wall -...

Is this because GCC does not implement this correctly yet?
 
@MartinhoFernandes Comeau complains as well when using comeaucomputing.com/tryitout .
 
Does Comeau work with the ints?
 
@MartinhoFernandes: No. Maybe it's a bug in gcc. `"ComeauTest.c", line 3: error: reference variable "ref" requires an initializer
int &ref{a};`
 
Now it starts to make some sense.
You can't use {} to initialize references.
You can only use it for types that support aggregate initialization or types that have a constructor that takes a std::initializer_list<T>.
I think.
And btw, using good old int &ref(a); is still "uniform initialization".
Uniform initialization is not about the braces.
 
you can use it for constructors that don't take std::initializer_list
std::initializer_list is simply preferred if both variations exist
 
11:24 AM
Ah, ok.
 
@MartinhoFernandes: int &ref(a) is syntactically different to int &ref{a}, that's what I meant. I think I will have to read more on uniform initialization :)
 
@MartinhoFernandes: what version of GCC are you using? I just tried on GCC 4.6.1 and int &r{n}; works.
 
@reko_t That's what evnu got. Now try it with a UDT instead of int.
 
ah
 
Comeau doesn't allow either.
 
11:30 AM
sorry, didn't read the question, just the chat
 
And btw don't listen to half of what I say today.
I'm not thinking straight.
 
@MartinhoFernandes Which half should we listen to then?
 
@MartinhoFernandes But the suggestion to try int& ref{a} with comeau was useful :)
 
@StackedCrooked The one that makes sense.
 
@MartinhoFernandes Ah, ok.
 
11:37 AM
Can you guys whistle?
 
@MartinhoFernandes yes, also with my fingers and I used to be very proud of that.
 
I've been trying all my life, and I can't get that to work.
It's frustrating because it seems so easy.
 
And I find it difficult to make smalltalk with normal people. We all have our deficiencies.
 
@StackedCrooked Is smalltalk that kind of chat about the weather and such?
 
@MartinhoFernandes Maybe he's talking about the object-oriented language. It makes more sense.
 
11:45 AM
good morning
 
Small talk is conversation for its own sake, or "…comments on what is perfectly obvious." It is an informal type of discourse that does not cover any functional topics of conversation or any transactions that need to be addressed. The phenomenon of small talk was initially studied in 1923 by Bronisław Malinowski, who coined the term phatic communion to describe it. The ability to conduct small talk is a social skill. Purpose In spite of seeming to have little useful purpose, small talk is a bonding ritual and a strategy for managing interpersonal distance.Bickmore, T. (1999) A Comput...
Ok, I'm not very good at that either.
 
"The ability to conduct small talk is a social skill."
Looks kinda hard actually
 
I have that method in my base class
 
What method?
 
smalltalk()
 
12:15 PM
> Here's what most people got out of Design Patterns: "blah blah blah blah SINGLETON blah blah blah blah"
3
From Steve Yegge's Singleton considered stupid sites.google.com/site/steveyegge2/singleton-considered-stupid
 
When I read the design patterns book
I felt like it suddendly became best practice to use global variables
 
it's so easy to get c++ wrong isn't it
and OOP in general
i'm reading that link @StackedCrooked posted, so embarrassingly familiar
 
@hexa Yes I feel that too. My past self is so lame.
 
12:31 PM
believe me, im not where you are in terms of OOP'ness, and not where the guy in the article was when he started with java. I'm somewhere in between still. The good thing is, the more i study C++, the more i realize that I almost always had a OOP mindset, just did not have the tools (in my very good friend C) to do it
it's a work in progress :P
 
@hexa Well, I don't really know where I am in terms of OOP myself. We started at school by doing OOP C, which was I think, catastrophic.
 
@hexa: The trouble with that is that nobody is ever where anyone else is
objects and the right design are so difficult to do, that it's easy to think that someone else always has the better design
 
@DeadMG There are also people who always think their design is better.
 
true
but I used to think that my API design was hawtness and now I'm really not so sure
 
I think it's ok as long as there are no errors
I've never seen a perfect API/library
 
12:46 PM
true
there are some designs which just suck though
 
And stuff like boost is too complex for me to make an opinion :)
@DeadMG Totally. like strtok()
 
lol
non-thread-safe globals based APIs aren't suck, they're fail
 
and lazy
 
Yeah, it's the highest level of badness
 
well
I figured that most of my logic is actually irrelevant to the renderer in question, so it was stupid to put it in a renderer-specific place
DRY and all
 
12:48 PM
no, badness is having a bug, knowing about it during all your dev cycle and releasing the code anyway.
 
but I'm not completely sure wtf to do now
 
What are you doing ?
 
designing an API for the hardware-accelerated rendering of 2d sprites and text :P
I already have (most) of the implementation down
 
Oh yes I remember having a discussion about that.
SDL is commonly used, but it's way too instrusive and bulky
 
no, I've written my own in Direct3D
and that's the way I'm keeping it
definitely moving on to 3D when I feel satisfied with what I've done in 2D
 
12:51 PM
ok
 
the trouble is
I have a bunch of classes which are really just a bunch of member variables
if you want to render a label on the screen, all you need is some text and a position and a font, fundamentally
but I need to push the changes to the GPU when they change, so I can't make them empty classes
and I also don't want to leave the user responsible for pushing the changes
ideally, I would have a proxy object that implements all the methods
 
you shouldn't
 
and then just set the dirty bit
 
if i understand you right, more often then not i saw a "guy" calling redraw() 1000 times per second
 
oh, that's not in my API
 
12:57 PM
when in the end, you have like... a 60hz vsync
 
the objects magically draw themselves behind the scenes
if they're not visible, anyway
I need to split them down into Contexts and then you pick which Context(s) to draw, really
 
are you coding a game?
or just some drawing platform?
 
does it really matter?
 
not really, for your design i mean. im just curious :P
 
so you have some couples of getter/setters ?
or just public member variables ?
 
12:58 PM
lol
I can't have public member variables
if you change them, then the changes won't be reflected, because they haven't been pushed to the GPU
unless I kept a distinct copy and compared all the variables every frame
 
I already seen that, true story
So what is the problem with the dirty marker ? It's a common idiom
 
well, I figured that all the renderers are gonna need the same dirty marker
so instead of implementing it as a pure abstract interface, it would make more sense to make it renderer-independent
is my current line of thinking
but I'm not too sure how that would look
 
can't the functions that change the state push the changes to some intermediate manager class that batches the operations to be flushed once a frame or something? that sounds like a cleaner solution than marking things as dirty, and iterating over dirty instances once per frame to aggregate what needs to be updated
 
what is implemented as an interface ? the renderers ?
 
@rekot: The implementation of the dirty is quite irrelevant
@kbok: Yep
 
1:05 PM
Ok
I would have thought of the renderers depending on the drawable classes, so no need for interface definition
 
the renderer depends on the hardware and operating system
 
just something like adding/removing stuff
 
no good picking a DirectX 11 renderer if I'm running on Windows XP
 
Yeah, I mean depending in terms of dependency graph
 
but in all seriousness, don't directx provide 2d acceleration cross platform already?
 
1:07 PM
I have no idea wtf you're asking
 
what do you mean cross platform ?
 
2d acceleration, directx has it, right?
 
DirectDraw? Wasn't that deprecated?
 
cross windows
 
@hexa: Only for Vista and above- and if you want to run your 3D in DX 10
besides, I don't really care, because this is just a first step for me to get some practice for some interface design before moving on to 3D
I already have some 3D implementations
so only 2D stuff won't exactly fit my bill
 
1:09 PM
I see, it's probably a very good way to practice
 
sure better than just talking about it on SO
 
Guys, do you know about any problems that installing VS 2010 along already existing VS 2005 installation could cause?
 
no
ok, I had an idea
maybe the Set function should just return a mutable reference
I mean, I'm not trying to abstract my variable here, I'm trying to catch changes
 
1:23 PM
milk+honey+coffee
does that sound nice?
i mean, no water in it
All of SO is horny
219
Q: My God—it's full of unicorns!

balphaBased on this comment, I have started building a unicorn avatar maker. It's still quite ugly, and the results aren't different enough yet, but this is what it looks like so far: Question list / Joel's profile (removed the images from here to make this thing a little shorter). Is this just way t...

 
> For instance, try adding multithreading in and see what happens. Well, I'll tell you what happens: half the time, you get a Doubleton or a Tripleton, unless you're a synchronization expert, and having a Tripleton is about as desirable as having three Balrogs show up at your tea party.
:D
 
1:50 PM
139
A: My God—it's full of unicorns!

KopJeff, you must change the default avatars on S[OFU] to unicorns on April 1st. MUST. Ok this was implemented... I'm sooo happy now :D Thanks Jeff!

Let me get this straight.
All the things that are done to restrict users, and the battleground that is meta, and so on..... and this is implemented, no questions asked....
0
A: My God—it's full of unicorns!

XaadeThis just broke my sarcasm for the day.... Horny Ponies.... Or maybe not. I think it would have been a little better if you made the mouth a rounded rect instead of a line. That way you'd have more control over the look of those with "fatter" mouths.

 
2:30 PM
To be fair, I think @balpha was not on the SO team at the time. Even if he was, he implemented the unicorn generator on his own. All the SO team had to do was to change all gravatar urls to the unicornatar.
 
2:48 PM
@kbok You almost make it sound like OO is the final goal or something. It certainly is not.
 
@FredOverflow That wasn't my intention.
 
5
Q: What is the strongest evidence that anti-matter exists?

Zach GirodEvery space show I watch mentions that anti-matter used to exist, or still does and we just can't detect it. I think some shows even say we can create a small amount of anti-matter. It is not presented as an unproven conjecture like string theory, but rather as a fact. In terms someone without ...

lol, the answer is: "The strongest evidence that it exists, is the fact that it actually exists."
 
3:13 PM
funny mousepad:
we have silicon mousepads at work too. but they haven't got such nice design
 
Uhm, little help?
6
Q: structs and inheritance in C++

maxpayneThis is an interview question and I will appreciate some answers. Consider... struct A {}; struct B : A {}; A a; B b; a = b; // line 1 b = a; // line 2 Why does Line 2 throws an error, while line 1 is perfectly fine?

Why does this work? The answers so far are wrong (though highly upvoted).
(I’m assuming to simplify the underlying type system of pointers but this doesn’t make much sense to me …)
@Johannes Aaah. – But I suspect that most people (in particular, neither the OP nor the other answerers) will understand this answer. Mind expanding it?
 
3:43 PM
@JohannesSchaublitb Sizes seem somewhat disproportionate though :)
 
@KonradRudolph a widely used idiom is what MFC is doing. I.e class CPoint : tagPOINT { .. }. deriving C++ classes from C plain structs
and then being able to assign a CPoint to a POINT struct
I agree that such slicing is ugly tho
 
Correct me if i'm wrong : the c++ compiler generates A::operator=(const B&) ?
 
@kbok you're wrong xD
the compiler only creates A::operator=(A const&)
 
and passing a B where it expects a A& is fine ?
 
why wouldn't it? sure it is
 
3:46 PM
Well yeah, that's public inheritance for you
 
It's a big deal in OOP: polymorphism.
 
So the slicing mechanism is just copy-constructing to a supertype ?
 
@kbok Copy construction or assignment, yes
 
while slicing is bad, I can't immediately see a problem though. Yeah you will kill some information from the object, but since every B is-a A, it seems fine to me that you can get the A from the B
independently
 
this site : devx.com/tips/Tip/14570 (dunno if it's correct) says the vtable is copied as well, so reference to nonexistent instance variables can happen
 
3:50 PM
anyway. the c++ type system is unable to prevent this.
 
@kbok That link doesn't say that at all (about references)
 
@JohannesSchaublitb if I slice, is the sliced data still in memory but the class doesn't know how to access it or is it removed?
 
I must have misunderstood
 
i don't understand
 
anyway, gotta go. I'll have a look later.
 
3:54 PM
ah now i do
the data is just not copied.
there is nothing "leaked" or something
it's like int a[3]; int b[1] = { a[0] };
 
ok so it only fetches the data it needs and does not know about anything extra
 
Slicing can be undesirable behaviour but it can never be invalid behaviour.
 
@ÓlafurWaage Think how you would write the copy assignment operator A::operator=(const A&).
 
struct Food { int calories; }; struct Bread : Food { int butter; }; Food food = Bread(); // Slicing bread has never been easier...
5
lol
 
haha
@MartinhoFernandes ahh ok, I never got the underlying behavior :)
@JohannesSchaublitb ok so when it is copying the data from Bread into memory it sees that it needs a Food and it copies Bread like it was Food?
 
4:01 PM
@ÓlafurWaage Are you aware that a derived object can bind to a reference to base? i.e. Bread bread; Food& view_as_food = bread;
 
ya, I know the functionality, just wondering about the underlying behavior
as in, what is actually happening under the hood
 
The compiler would implicitly create something like Food::operator=(const Food& that) { calories = that.calories; }
Which explains why slicing happens.
 
@MartinhoFernandes ok thanks, that's what I was wondering.
 
You can't in any way keep the butter in that function because 1) you don't even know the butter exists and 2) you have no place to store the butter.
 
The behaviour is thus similar as if Bread bread; Food const& const_view_as_food = bread; Food food = const_view_as_food;
 
4:21 PM
in a way struct A { A(int) { } }; A a(0);` is also "slicing" because it throws away the int
 
Yeah but that broader definition of slicing is less useful.
 
So A(int a) isn't slicing in that sense?
 
it's slicing
the int contains the same information as the A, and more
but the constructor takes none of those information
 
Ok, so just because you do not have anything to receive the variable?
 
And the moral is: make constructors explicit.
 
4:24 PM
you "slice" it away
 
@LucDanton I learned that one fast.
I find it a little annoying.
 
Have a great weekend everyone.
 
@MartinhoFernandes tbh the real thing that annoys me (beyond the fact that it should be the other way around with an implicit keyword) is that I still want to write just return { a0, a1, a2, a3 };
 
I think you can do that in C++11.
And I agree with the explicit implicit keyword.
 
4:38 PM
No you can't unless there's an implicit conversion.
Writing stuff like std::unique_ptr<T> foo(U bar) { return std::unique_ptr<T> { new T(quux(bar)) }; } is tedious.
Also I discovered that it's not always acceptable in generic code to write T t { std::forward<Args>(args)... };. It fails for T = std::vector<double> and Args&& = { int, double }, i.e. generic_code<std::vector<double>>(42, 0.);
Uniform initialization is starting to be somewhat of a letdown beyond value-initialization of T {}
 
You always have to be careful with that because initialization with {} and with () are not the same thing, unless they are.
Yeah, that sucks.
 
4:56 PM
22
A: structs and inheritance in C++

Johannes Schaub - litbBecause the implicitly declared copy assignment operator of B hides the implicitly declared copy assignment operator of A. So for the line b = a, only the the operator= of B is a candidate. But its parameter has type B const&, which cannot be initialized by an A argument (you would need a d...

 
I wonder how much of C++'s popularity is thanks to it being used for game development.
 
@JohannesSchaublitb Could you create a copy constructor in B that takes an A?
 
@StackedCrooked 8.37%
 
Random Statistic alert.
 
76.37% of statistics are made up on the spot.
 
4:57 PM
@hexa I always thought it was 17.4% :D
 
@StackedCrooked that was before Wii dude
 
rand() * 100
 
overflow!
 
Who is Wii dude?
 
Wii is M!! upside down
 
4:58 PM
while (rand() < 1)
@hexa Mintendo?
 
#define if while
 
Hi, Can some experts help me on understanding between Inversion of Control vs Dependency Injection: stackoverflow.com/questions/6550700/… There are two sources which explains quite a bit different. I am confused.
 
Inver s ion
 

« first day (258 days earlier)      last day (4695 days later) »