« first day (453 days earlier)      last day (4485 days later) » 

9:00 PM
@RMartinhoFernandes: the one about ptr_list
seems counterintuitive
 
sbi
I didn't do it!
 
@sbi: Too late I saw you doing it
 
sbi
@Grizzly Psht!
 
@Grizzly You can put pointers directly into them, but what you get out of it are references to the objects themselves.
Notice how these two types differ:

typedef T* value_type;

notice this has pointer type

typedef T& reference;

notice this is not a pointer type

This is done to be able to add pointers directly to the container, but to hide the pointers externally.
 
@RMartinhoFernandes: I knew there was a reason why I don't use those
 
9:07 PM
That's exactly the reason I use them!
They're more like a container of references.
They're useful to have collections of polymorphic objects without getting bogged down by multiple indirection.
 
Last time I used a container with that kind of behaviour I alwas needed pointers
 
because that was the signature for most functions I needed to call
 
Well... why didn't they take references?
 
I might be prejudices against seeing &*it now
because it needed nullpointers
 
9:12 PM
Ah. I find the idea of storing null pointers in a container weird, but it might be some bias of mine stemming from the pervasive nulls in .NET.
Anyway, off to dinner.
 
@RMartinhoFernandes: The container didn't store nullpointers, but the functions could take a nullpointer
 
@Grizzly if you're dealing with pointers then &*it might not result in the correct type. However, you're probably dealing with value_type*, in which case it's pretty much guaranteed to work
 
boost::optional<T&>!
 
fixed-point multiplication/division/modulo is hard :(
 
@MooingDuck: Depends on the necessary precision
 
9:18 PM
@Grizzly I'm implementing (effectively) as a fraction with a templated denominator. Tricky part comes in keeping the required accuracy for intermediate results
 
If you can get away with 64bit for intermediate results its not that bad
 
std::ratio?
 
@Pubby Reinventing the wheel. Again. I know.
 
std::ratio is compile-time.
 
@MooingDuck: You do that often?
 
9:20 PM
@Grizzly I do little else unless supervised
 
Running into overflow problems or something?
 
@Pubby with multiplication yes. Now I'm off to figure out division
 
sbi
2
Q: Are the teletubbies cyborgs?

WikisLook at the evidence: As the name suggests, they have implanted televisions! Were they born that way or did they undergo some fiendish experiment?

OMG!
 
@MooingDuck If you have multiplication then division is the same thing :P
 
@Pubby multiplication was A.B * C.D = FG.HI -> (truncates to) G.H
@Pubby only theoretically, never in practice
 
9:22 PM
What do you mean?
 
@MooingDuck: Even in practice, it's just not that easy to convince it to do that
 
Is it rational or fixed point? :S
 
hey guise
 
@Pubby The line is a little fuzzy here. I guess technically fixed point.
 
@sbi: OMG indeed
@MooingDuck: So you want to support 64bit (or more) fixedpoint?
 
sbi
9:25 PM
@Grizzly I like DampeS8N's comment. I wish we had more of that spirit here at SO.
 
@MooingDuck Well, whatever the case there's some good stuff in TAOCP on that
 
@Grizzly I want to support dollars. The underlying type is specified by a template parameter, but thus far I'm assuming it behaves like`unsigned int`. (I"ll fixed signed later)
I still have to lookup how to friend a template class every time :/
 
sbi
@Pubby Interesting!
 
9:33 PM
@Xeo What's up?
 
sbi
"In the meantime, it's 13 years later, and I still need a girlfriend." ROTFL!
 
Xeo
@Pubby I like the Nightwish music!
@KerrekSB Err, I forgot. :(
 
sbi
@Xeo Well, you are up. (Of course, it's night time at your's, so this is to be expected...)
 
Xeo
But I'm going to bed Real Soon Nowâ„¢.
3
0
Q: c++ how to reduce the amout of identical template specializations?

markI have this functor: struct functor { template<class T> void operator()(T value) // (*) { // process the value } template<> void operator()<const wchar_t *>(T value) // (**) { if (value) { // process the value } } template<> v...

This guy doesn't quite seem to understand templates.
 
No template specializations in-class makes me sad
 
sbi
9:45 PM
@Pubby It qouldn't be able to do that to you anyway, because it doesn't exist.
 
@sbi What?
 
@Xeo Even if the original example were correctly spelt, it would never work, woudl it?
Because overload resolution doesn't consider specializations?
Oh, maybe it would, because there are no non-template overloads.
 
sbi
@Pubby "No template specialization in-class would ever be able to make me sad."
 
Xeo
Yeah, it would "work"
 
@sbi Well then it's the non-existence of them that makes me sad. Very sad.
 
sbi
9:49 PM
@Pubby Oh, of course, that's what you meant! Alas, I never dreamed that this could be the meaning of your statement! :b
 
lol
wow, did everyone leave?
 
sbi
@TonyTheLion I'm still here, but I'm going to go to bed Nowâ„¢.
 
right, good night then
 
Yeah, "now". Right.
 
sbi
@TonyTheLion Good night!
 
10:00 PM
ok he's gone then :P
I have my doubts....
it's only 11, the night is long and .... well, long
isn't this taking memes a bit far?
 
The definition of memes is taking it too far.
 
Xeo
14
Q: How bad is "if (!this)" in a C++ member function?

CrashworksIf I come across old code that does if (!this) return; in an app, how severe a risk is this? Is it a dangerous ticking time bomb that requires an immediate app-wide search and destroy effort, or is it more like a code smell that can be quietly left in place? I am not planning on writing code tha...

Wow, 14 upvotes in 20 minutes
 
10:17 PM
Wow indeed
 
Xeo
Oh, and a wide range of close votes xD
Exact duplicate, not constructive, off topic..
 
I can see how it doesn't have a concrete answer though...
 
I don't know about duplicate, but how is that not constructive or off topic?
 
@Xeo I think it's a good one.
I'm voting to reopen if it gets closed.
 
Xeo
10:19 PM
Yeah
 
I don't agree with off topic. But not constructive makes sense - though no where near to the point where it should be closed
 
Xeo
It does have an objective answer - out with the test and fix the call site
And it has a subjective answer
Because, you know, huge legacy codebase
 
The road to hell was paved with huge legacy codebases?
 
If you have an amazing answer to add, that's the kind of question that will give 100+ votes if you can give a concrete answer that everyone agrees with.
 
can I have a static const type stuff = 4; where type is a template parameter that is unsigned int?
 
10:22 PM
@Mysticial: you mean a way to change it without working overtime?
 
@MooingDuck Sure, why not? Did you provide a definition?
 
@MooingDuck If you give it a name.
 
@MooingDuck: Any reason you should not be able to that (aside from not giving it a name)?
 
@FredOverflow turns out std::integral_constant<unsigned int, 10>::type is not unsigned int. I learned something new today!
 
Xeo
@Mysticial You can't provide an answer everyone agrees with
@MooingDuck What?!
 
10:24 PM
@Xeo or I have a bug, one of the two
 
@MooingDuck: Of course not
 
Xeo
	// TEMPLATE CLASS integral_constant
template<class _Ty,
	_Ty _Val>
	struct integral_constant
	{	// convenient template for integral constant types
	static const _Ty value = _Val;

	typedef _Ty value_type;
	typedef integral_constant<_Ty, _Val> type;
	};
 
@Xeo Which is what I'm saying. If you're able to pull a curve ball and get everyone to agree. Automatic 100+ from what I've seen... given the rate of the votes that this question is getting.
 
it is std::integral_constant<unsigned int, 10> if I remember correctly
 
Xeo
This is how it should look like in your compiler
 
10:25 PM
@Xeo I didn't look, I just typed ::type and figured if it didn't compile then I'd look
 
Xeo
@MooingDuck type is integral_constant<T, V> itself
 
makes TMP much easier that way, since having one or two ::type too many doesn't break your code that way
 
Xeo
I think you're looking for ::value_type
 
@Xeo I noticed
@Xeo I was
 
template<typename type> struct Foo { static const type x; };
template<typename type> const type Foo<type>::x = 4;
int main() { std::cout << Foo<unsigned int>::x << '\n'; }
 
10:27 PM
You can initialize static constants in-class, can't you?
 
You can? I wasn't sure.
 
At least integral ones.
 
@RMartinhoFernandes: Only integrals I think
 
Well, then my solution works also for UDTs :)
 
@Grizzly Even for C++11?
 
10:29 PM
@RMartinhoFernandes C++11 loosened the rules slightly, but I can't recall what to
 
@RMartinhoFernandes: I'm not sure, but is that even relevant considering constexpr?
For constexpr it doesn't it works whether it's integral or not from what I remember
 
With constexpr it works for "literal types". Or something like that.
That part is in serious need of improvement.
 
@RMartinhoFernandes: Ok it seems it works for literal types (just like constexpr when using static const
 
I think we violated this, we have a self-aware robot in this room
 
@TonyTheLion: Don't know, did it become selfaware in the last 68 days?
 
10:40 PM
@Grizzly donno, would have to check with Mr. Robot himself really
 
19
Q: How gcc optimizes c code

HaileI wrote this simple c program: int main(){ int i; int count = 0; for(i = 0; i < 2000000000; i++){ count = count + 1; } } I wanted to see how gcc compiler optimizes this loop (clearly add 1 2000000000 times should be "add 2000000000 one time"). So: $ gcc test.c and then ...

 
@robot, when did you become self-aware
 
You've earned "Good Answer" and 103 other badges. See your profile.

Hey, didn't realize how many votes that picked up while I was doing laundry.
 
jeez that's a lot
 
I don't clear my badge notifications, lol
 
10:43 PM
@Mysticial It's very refreshing to see a first-time asker asking a very well researched question.
 
@RMartinhoFernandes Exactly. That's definitely very rare...
 
And and on top of that, it's a non-silly question!
 
@sbi wow
 
bah. Just spent two hours debugging my fixed point multiplication. Turns out it was the output algorithm that was rounding, not multiplication
 
10:59 PM
0
Q: Game Engines with that use PHP for scripting?

McTwistI am looking for a game engine that uses PHP for scripting purposes. For example, Lua is used widely as a scripting language for many games. I would like to have PHP as scripting language instead of Lua. If there is no engines with PHP scripting, is it possible(Apache could) to add a module to P...

Gosh, just thinking that someone could think this exists...
 
ugh. why would a question like that even come to mind??!!!
 
@RMartinhoFernandes Oh the horrors
@MooingDuck Learning by crying.
 
11:21 PM
lol
 
hi
 
hey guys
 
Can anybody help me to get a better understand of inodes, vnodes, get_inode and get_block?
 
what is the quickest way to replace a key with another one? I have a map of highscores, where i have the initials and the score. I want to erase the last score and insert the new score, so when iterating through it i have all of the scores sorted.
 
Use a circular buffer?
 
11:27 PM
@coolbartek: That doesn't exactly sound performance critical
 
i thought about vectors, but it seems clearer with maps
 
so I would go with erasing the last score and inserting the new one on a std::map
 
but the point is that the newest score is not neccesarily in the right position
 
@coolbartek If the map is ordered by score, yes, it will be in the right position.
 
What is the exact map type?
 
11:30 PM
http://tldp.org/LDP/tlk/fs/filesystem.html
http://tldp.org/LDP/khg/HyperNews/get/fs/vfstour.html
 
map<std::string, int>& scores
 
@Charlie In other words, google Linux + VFS
 
Er, why a map from strings to int?
 
Then it will be sorted by the strings, not the ints.
 
@sehe im having a stupidly hard time figuring it out
 
11:30 PM
changing the order will be enough? :D
 
there is no documentation for minix and inodes
and no examples!
 
@Charlie it's not supposed to be simple
 
It has been a month and I havent moved any closer to completion
 
struct hi_score {
    std::string player_name;
    int score;
};
bool operator<(hi_score const& l, hi_score const& r) {
    return l.score < r.score;
}
std::set<hi_score> hi_scores;
 
@Charlie oh the horrors. So that was the version of the OS you were on - not linux at all
 
11:32 PM
this is a different project from the one the other day
this one is in minix 3
 
@Charlie Ok, but google minix vfs is turning up very promosing documents (PDFs, wiki)
 
I have done this for some time, my issue is that I cannot find a way to actually do it
I understand it theoretically
 
@Charlie Like I said, it's not supposed to be easy. We wouldn't want next-door-Jill to have their own OS-es and filesystem implementations, now would we
(only half kidding there)
 
What's wrong with Jill? She sounds like a smart person.
 
Yeah I know it isn't supposed to be easy but after a month of long nights it really makes you want to give up on it!
 
11:36 PM
Unfortunately, I'm afraid you'd have to look elsewhere (programmers.SE, serverfault(?)) for backup. You can always post concrete questions on stackoverflow.com, it seems to be a nice Q&A site.
@RMartinhoFernandes Give me a break. I thought long enough to get that phrased in 'engrish' in the first place :)
@Charlie I'm taking you can't give up on it?
 
shhhh!
haha no it is realllly pissing me off!
 
@Charlie You could make it more on-topic for this room if you recast all questions in terms of implementing a Boost Filesystem v3 abstraction layer that would work on your Steganographic Filesystem.
Or something ... :)
 
ha
So if i have an inode number, i cant just get_inode() straight from my code, I have to pass it to the VFS and then hope that will do it, it wont. Get_inode is nowhere to be found in VFS so i'm one giant mess
 
Speaking On-Topic: I wish to extend thanks to everyone who has endeavoured to give me rep on an intriguing SE daughter site: Engrish.stackexchange.com:
13
Q: Is there a word for someone with the same name?

seheIf a person shares my name, in Dutch there is the word "naamgenoot", meaning roughly 'member of the same name'. John A: Hi, my name is "John" John B: O, then we're insert solution word here! Similarly, 'classmate' is 'klasgenoot' in Dutch 'roommate' is 'kamergenoot' in Dutch I'm pre...

I'm really levitating gravitating towards name-fellow at this point in time, because it is a word I'd actually see myself using in the same situation
 
11:45 PM
Morning.
 
@sehe is se t he?
 
Woot, I repcapped with that answer with the pictures alone.
I gotta put pictures more often.
 
@Pubby Nope. Just Seth
 
(Sorry for the pings, please direct them to cat)
 
It's actually the first letters of my first name, and the first of my... lastname.
@Pubby (someone set us up the pling! move all zig! activate deflection shield! for great justice!)
 
11:50 PM
@sehe All your pling are belong to us
 
That happened to be the naming convention for users at my first job, and it kind of stuck. I'm still employed at the same company, though I'm now proudly known as She12345 (digits fictitious)
@Pubby That line would have been so much more WIN if it were posted by @CatPlusPlus (oh, -pling- hi, Cat!)
 
It's "plink".
@sehe lol
 
You can see why I stick with sehe. It is short, and I am lazy.
 
one more question, the last item in the map is scores.end()? (as an iterator)
i get out of range when try to erase an item with that iterator
 
no, scores.end() is one past the end of the map
 
11:55 PM
scores.end()-1
 
can i do scores.end() - 1?
thanks
 
Or scores.rbegin()?
 
no you can't
map doesn't have random access iterators
 
@RMartinhoFernandes --scores.end()
 
so how should i do it?
 
11:56 PM
--scores.end() would work though
 
alright thanks
 
So if I have three integers and need a*b/c, where do I find a algorithm to calculate that accurately. (note the concern is either rounding or overflow in the temporary, thus this is non-trivial.
 
@MooingDuck Want to use my super approximation?
 
@Pubby I'm attempting to not use float/double as well, is that relevant?
@Pubby if the approximation is a*b/c then no :P
 

« first day (453 days earlier)      last day (4485 days later) »