« first day (538 days earlier)      last day (4408 days later) » 

Tin
9:01 PM
what valid parameter for mt19937 would you suggest?
 
@MooingDuck Sorry, I was still talking about Kerrek SB's statement about pointers in C++ which I would rephrase to: "Use pointers (especially bare ones) responsibly!"
 
@Tin it's hard to argue with that
@Andre Oh that. Because I know(ish) Kerrek and I know C++. We frequently tell people not to use raw pointers.
 
Tin
@MooingDuck, but yes, in the example the range consisted of two integer numbers: std::uniform_real_distribution<> dis(1, 2);
 
std::mt19937 engine1(static_cast<std::mt19937::result_type>(rd()));
 
Tin
what I couldn't still find is which are the valid std::string parameters for std::random_device
i couldn't find a documentation for that
 
9:05 PM
If you want random floats, then it's probably better to use uniform_01_distribution and generate in [0,1].
 
@Tin it's implementation defined, you're not supposed to touch that
 
Floats are more precise in that range.
 
@MooingDuck I would advise against using raw pointers, too, but smart pointers aren't a silver bullet, either. His statement is just not generally true (despite having the word generally in it).
 
It might throw on ideone because there's no access to /dev/urandom.
Or any file for that matter.
@Andre If you have an owning raw pointer, you're doing it wrong.
 
@Andre it's generally true, just not always true.
 
Tin
9:08 PM
@MooingDuck, what does the std::mt19937::result_type does exactly?
 
@Tin According to MSDN, random_device::operator() returns a unsigned int, and mersenne_twister constructs from a unsigned long so it was going to the template constructor instead.
@Tin nevermind that, that was wrong too
 
@MooingDuck ok
 
Tin
@MooingDuck, so the std::mt19937 engine1(rd()); was correct, then?
 
@CatPlusPlus So, boost::shared_ptr is doing it wrong. ;-)
 
@Tin The more I look at MSDN's docs, the more I have no idea how to initialize a mt19937
 
9:09 PM
We're talking about client code, not implementation of safe constructs.
 
Tin
@CatPlusPlus, thabks for the suggestion, but I couldn't find a reference to uniform_01_distribution and I would like to generate random numbers between [0,x], where x >= 1
 
Generate ints, then.
Or maybe I just don't like floats.
Because I don't.
 
@Tin The possible constructors are: "explicit mersenne_twister(unsigned long x0 = default_seed);" and "template<class Gen> mersenne_twister(Gen& gen);", but I don't know which cppreference was trying to use.
And MSDN gives no example code there
 
It's using the seed one.
Takes seed from /dev/random or equivalent and creates a deterministic MT19937 engine out of it.
 
 unsigned long seed = rd();
 std::mt19937 engine1(seed);
 
9:12 PM
8
Q: RVO for complex user-defined types in C++

André CaronIn an programming interview I had yesterday, one of the programs I had to write ended up having something like this: struct Blob { // basic field containing image blob statistics. }; std::vector<Blob> find_blobs (const Image& ...) { std::vector<Blob> blobs; // ... ...

 
std::mt19937 engine1(rd); should do the same.
 
@CatPlusPlus but their random_device returns an unsigned int, so you have to cast to get the seed
 
The Lempel–Ziv–Markov chain algorithm (LZMA) is an algorithm used to perform lossless data compression. It has been under development since 1998 and was first used in the 7z format of the 7-Zip archiver. This algorithm uses a dictionary compression scheme somewhat similar to LZ77 and features a high compression ratio (generally higher than bzip2) and a variable compression-dictionary size (up to 4 GB), while still maintaining decompression speed similar to other commonly used compression algorithms. LZMA2 is a simple container format that can include both uncompressed data and LZ...
 
@MooingDuck So?
long is the same or larger, so there's implicit promotion.
 
@CatPlusPlus it's wierd that they wouldn't make those match
@user1131997 welcome back :/
 
9:13 PM
Why would they? The two are completely unrelated.
 
Tin
does this would also make sense?
std::random_device rd;
unsigned long seed = rd();
std::mt19937 engine1(seed);
 
@user1131997 your id is similar to the mt19937. I knew it looked familiar.
@Tin yes
 
@MooingDuck thank for the welcome! :)
 
@MooingDuck did I miss something?
 
@user1131997 so what?
 
9:14 PM
@CatPlusPlus eh, I guess that's true
 
^ you discovered wikipedia?
 
@Abyx I'm trying to use it in my algorithm collcetion :)
 
Wikipedia is nothing compared to this wiki.
 
@Abyx than shall try it in dynamically work with alot of data
 
sbi
2 hours ago, by sbi
So userXXXXXXX has been trolling again, huh? And pissing off the puppy? And then @jalf, of all people, was suggesting a be-nice policy? @Dead: Just ignore this guy. I've been doing this for a long time now, and if you'd all just do this (and, thus, all stop responding to him), this room would be a much better place. @jalf: The guy might be beyond niceties. He's one of only three users I have blocked, I did this months ago, and he's still pissing off people.
 
Tin
9:15 PM
or just simple: std::mt19937 engine1(rd); as @CatPlusPlus suggested should do the same
 
Also LCG > MT19937.
 
Tin
@CatPlusPlus, i still didn't get the suggestion on generating ints?
 
State of MT19937 is huuuuge.
 
@user1131997 ok, try it, but don't post random stuff here, without any explanations
 
And let's be honest, you don't need period that large.
 
9:17 PM
@sbi I see…
 
Tin
@CatPlusPlus :-)
 
@CatPlusPlus honestly, what I need 99.9% of the time is rand()
 
@Abyx it's not random
 
@user1131997 to us it is
 
@user1131997 for you, maybe
 
9:18 PM
@MooingDuck @Abyx sorry :(
I just like algorithms... Wanna to make extension-library for each algo and testing in program to ( like internal unit-tests )
 
@user1131997 it looks you like to show that you "like algorithms".
 
@user1131997 me too. And discussing them is fine. Random links are not fine.
 
just looks so, dunno if it's true
 
Ell
Should I go signals route, or virtual OnThis, OnThat, and OnTheOther route?
 
Tin
@jalf, i followed your suggestion on adding default values for the template parameters: ideone.com/i8gqe is that what you meant, right?
 
9:20 PM
@Ell you don't need signals for zipping
 
Ell
@MooingDuck zipping? I mean for windowing events - window resized, mouse down etc. Sorry for lack of context. Actually I will open a question on SO after looking if one exists
 
@Ell nor virtual. Nor for any other algorithm I can think of
 
@MooingDuck That's LCG, but with crappy interface.
 
@Ell wow, yeah, lack of context. You were talking about Lempel–Ziv–Markov chain algorithm last I checked :/
 
I like boost::rand48. Dunno why it's not in C++11's std.
 
9:23 PM
@CatPlusPlus Yeah, bad interface. Easy to work around though
 
Tin
@MooingDuck, @CatPlusPlus I also saw some examples where people initialize the engine like this:std::mt19937 engine; engine.seed(0);
 
Ell
@MooingDuck haha sorry I tend to randomly talk about something without even introducing the topic, apologies for that!
 
@MooingDuck You can use rand_r, but meh.
 
Tin
i couldn't find an explanation when to use for instance: engine.seed(0) or engine(rd())
any ideas?
 
You use static seed to reproduce the results.
And really only then.
 
9:25 PM
@Tin yeah, that works too
 
Tin
@CatPlusPlus, sorry, i didn't get the part of to reproduce the results.?
 
MT19937 is a pseudo-random generator.
 
@Tin engine.seed(0) will give you the same "random" numbers every time you run the program. The other one will be different every time.
 
It does some crazy math to transform the state and yield a 'random' result.
 
It's really nice for debugging.
 
9:27 PM
@sbi I wonder whether we have the same three users blocked :) To be honest is more like 1-3 ignores varying a bit. But these 3 are very quickly back on the list when they annoy me
 
It's completely deterministic. Knowing the seed, you can predict all the numbers.
 
@CatPlusPlus be interesting to see a comparison of the speeds of the RNGs.
 
@MooingDuck Boost has that in docs.
 
@CatPlusPlus neat
 
rand48 is faster and smaller than mt19937.
 
Tin
9:28 PM
great, thanks for the explanations! so as a rule of thumb, one could say, if debugging mode use seed(0) otherwise rd()
 
std::mt19937 eng(0); is the same as std::mt19937 eng; eng.seed(0);
And it doesn't really have to be 0.
 
@Tin don't do all your debugging with 0, but it's handy sometimes to reproduce "random" bugs
 
Or obtained from random_device.
It's bad rule of thumb.
Oh, maybe it's not faster. But it's definitely much smaller, it requires only one int AFAIR.
 
Tin
or could we see that issue, as: if i need to generate different random numbers, every time i run the program then one shall prefer to use rd()?
 
Yes. Or current timestamp, but random_device will be much less predictable.
Though that's mostly important for cryptography, and dunno if MT19937 is even suitable for that.
 
9:36 PM
Has anyone done an SEH exception handler with g++?
 
I only use SetUnhandledExceptionFilter.
I think MinGW doesn't support __try/__catch.
Ooh, now you can get up to 16GB from refs on Dropbox.
Neat.
 
Tin
@CatPlusPlus, @MooingDuck thanks guys!
 
@CheersandhthAlf you can set it manually (set fs:[0])
 
@CatPlusPlus as student you could always get that much, maybe it's 32 now? EDIT: checked the blog, and no just for all now
 
but it's pointless in g++, because you can't start stack unwinding from the handler
 
9:40 PM
@Abyx well yes maybe, thanks, but i feel uncomfortable messing with that...
@CatPlusPlus thanks! i think that's probably bestest
 
@bamboon Dunno.
 
@CatPlusPlus see my edit
 
@CheersandhthAlf, btw, such question looks as XY. What's the final goal?
 
Handling SEH exceptions, I'd guess.
 
there are three or more ways to do it
 
9:46 PM
@Abyx good catch. :-) just in passing, i think, when you refer to XY, perhaps link to one of the description so person will understand... anyway, thanks.
@Abyx well there is the final filter, and perhaps assembly level messing, and maybe vectored filter?
 
There's VEH routines, but that's really only when you need more than one top-level handler.
 
@CheersandhthAlf yep. VEH, SEH frame, SetUnhandledExceptionFilter
 
I already mentioned SUEF.
 
@CatPlusPlus VEH is "bottom-level", it catches exception before SEH frames and UnhandledExceptionFilter
 
Maybe. I only ever use this for crash dump generation.
 
10:04 PM
I just head this idea of having ERB-like templates but for C++. ideone.com/p76gR
I think it sucks, to be honest…
 
Yuck.
Never mix presentation with business logic. And template engines are generally better at presentation logic.
And it's easier to work on them if they're loaded dynamically.
 
I think I might design something simple that you can just have loops, if and access the view data (and eliminate the any_cast, at least).
 
I wanted to write C++ template engine once.
 
It's not intended for business logic, just presentation.
 
It's ugly for presentation.
I mean, would you want C++ errors in a HTML template? :P
 
10:09 PM
It wouldn't be too bad with #line control.
 
It's not just that.
Well, implement it and sooner or later you'll see.
 
I'm sorry but if I see one more person use an XML-like language for UI/presentation code I will hit somebody over the head with a baseball bat
 
You mean HTML? :P
 
@CatPlusPlus: Yes. :-)
 
@Insilico HTML is about the only decent option for web pages, which are what's going to be rendered.
 
10:11 PM
I am of course being tongue-in-cheek, but I've seen enough XML/HTML/SGML/XAML/*ML stuff. :-P
@daknokt: That is true. I don't think it's as bad as XML though, since it seems like everybody's been using XML for everything.
 
I have XXXXXX Some text. in LaTeX, and that text overflows to a new line. Anyone know how to indent the next line by the width of XXXXXX automatically?
 
I like Haml, I might implement a compiler for that which uses C++ code instead of Ruby.
 
I lack ideas of what to look for.
Parbox maybe?
 
@CatPlusPlus: So you want something like this?
XXXXXX asdfasldkgjal;ksjdflkjasdf
       asdlfkja;lskfdjkljasdlfkj
       a;weoiruj;lkazsjg;lk
 
Yeah.
 
10:15 PM
Would parsing Haml be doable with Boost.Spirit?
 
@Insilico my company uses XML for everything, even inter-process communication. :/
 
@daknok_t Probably.
 
@CatPlusPlus: Maybe you can put SomeText into a minipage
 
Your company sucks.
 
@MooingDuck: Why? XML is an unbelievably inefficient way to transfer things via interprocess communication
 
10:16 PM
@CatPlusPlus well the pay and people are good anyway :)
 
hi guys
 
@Insilico I'm very aware of that
 
and also :
1
Q: How do I run POCO C++ server pages?

sehecommented: for info, also look at klone, google Native Client; Not that I recommend doing websites in C++, but just showing the other options

 
Question: Should a programmer really needs to learn more than just C, C++, and Java?
 
@daknokt Mainly the links in the comment^^
@tom_mai78101 You should learn how to wipe your butt, and possibly how to ride a bike
 
10:19 PM
I'll check it out!
 
@tommai78101: Well, the good ones learn more than just the minimum required
 
Though I think I'll go with Haml.
 
@sehe Uh... That was 17 years ago.
 
@Insilico Hm, it works, but XXXXXX is centered vertically.
 
@Insilico So, do good ones learn a language at a fast or decent rate?
 
10:20 PM
Oh, wait, [t] does the trick.
Thanks.
 
@CatPlusPlus: Yeah I just tested it out
I was just about to point out the use of [t] to make it work
 
> Prefixing messages with "Off-topic: " is redundant in this room.
If prefixing is redundant, I'm going with suffixing. Off-topic.
 
@tom_mai78101 The good ones understand the language they use
And more importantly, know what they don't understand about the language
 
@tom_mai78101 Mentioning that your messages are off-topic is redundant in this room.
 
How long it take is irrelevant (of course, if it takes you months you might have a problem)
 
10:22 PM
@daknok_t But, suffixing messages as "off-topic" is of different yet parallel story.
 
Although typically the good programmers have very little trouble picking up a language
 
@Insilico I see.
 
Fortunately lots of concepts transfer over to other languages pretty well
 
@Insilico Unfortunately, syntax don't transfer as well as concepts.
 
So it's not like starting over every time you learn a new language
 
10:24 PM
I really had trouble learning Haskell after doing years of Objective-C, for example, but learning Ruby was a piece of cake. The syntax doesn't matter, it's the concepts.
 
@tommai78101: True, but syntax is something you can look up
Ability to program is, unfortunately, not the case
 
@Insilico the hardest part to me is learning the new libraries :/
 
@daknok_t Wait... So, I mention my messages as "on-topic", that still counts as redundant? I'm losing my mind here.
 
@tommai78101: Yes, it's redundant because everything is on-topic in Lounge<C++>
 
@tom_mai78101 Nevermind, everything in this room is redundant.
 
10:25 PM
@MooingDuck Oh that... is damn good point.
 
@Insilico except C, PHP, and Java
 
@MooingDuck: Naw, they're on topic
We just bash them
 
Syntax is usually not a problem.
 
Java is something we use for Twitter hashtags.
#java
 
@MooingDuck I agree, which is why docs are especially important
 
10:27 PM
@CatPlusPlus If syntax is not a problem, then is anything possible, as long as there is time?
 
Except almost nobody knows how to write documents
@tommai78101: Pretty much
 
@Insilico Javadocs. To be honest, I don't use them a lot.
@Insilico Maybe we should create a eHow on how to write documents. :/
 
Seriously, I hate seeing shit like this: "Function: PlayMusic(); Remarks: Plays music"
WELL, NO SHIT.
 
@Insilico YOU DON'T SAY...
Great to see that I have more insights on programming languages.
 
  #define EIGHTY 256
 
10:30 PM
//what?
 
WTF?
Is 256 == 80 in some other number system?
It's sure as hell not hexadecimal
or octal
 
@Insilico It's the eightymal
 
SQWORD GetGlobalTime( const TCHAR* Filename ) {
  //return greenwich mean time as expressed in nanoseconds since the
  //creation of the universe.  time is expressed in meters, so
  //divide by the speed of light to obtain seconds.  assumes the
  //speed of light in a vacuum is constant.  the file specified by
  //Filename is assumed to be in your reference frame, otherwise you
  //must transform the result by the path integral of the minkowski
  //metric tensor in order to obtain the correct result.
 
I actually understood that. :-/
Don't know what that says about my character.
What's SQWORD?
Signed quadruple word?
 
10:33 PM
Word^2
 
The hell do you need a signed word to represent the time since the creation of the universe?
 
@Insilico From January 1 1970 to 2099 December 31, I think time can be reversed.
 
@tommai78101: Signed makes sense if you're talking about time deltas
But a negative value from GetGlobalTime() would imply a time before the universe existed
 
@Insilico Omg. Not another Win32 defined type.
Oh, the humor...
 
@tommai78101: Although to be fair, C++ doesn't specify the exact sizes for the integral types
 
10:36 PM
True.
They should also try making a class of std::string called BigInteger for infinite integral calculations.
And put it in the std namespace.
Same goes for BigDecimal.
 
@tommai78101: Why? There's very few cases where you need to do BigNum/BigDecimal calculations
And if you do, you're most likely doing super-specialist stuff, for which you use super-specialized libraries for anyway
 
@Insilico I'd be happy with standardized bigint/biguint/bigdecimal classes
 
Hm... Good point. 6:39 AM and I haven't slept. :/
 
@Insilico Well give me a decent std::decimal in C++ :)
 
Bigints are rarely strings.
 
10:40 PM
@MooingDuck: Me too. :-)
 
It's rather inefficient encoding.
 
private static bool InvertBool(bool org)
{
	bool returnValue = false;
	if (org)
	{
		returnValue = false;
	}
	if (!org)
	{
		returnValue = true;
	}

	return returnValue;
}
 
@Insilico thank goodness for optimizers and inliners :/
 
That's not 'rarely useful' - it's actually everyday required: float and doubles are things you rarely need.
Floating point are often used in number crunching _out of performance considerations_, but really, for most other applications people should be using decimals with large precision instead.
@ScottW Roman numerals, what about it?
 
@MooingDuck: Someone should make a compiler that generates horribly inefficient code when it detects something like InvertBool() :-P
 
10:42 PM
@Insilico MS compiler works wonders when you have /slowness flag turned on.
 
@ScottW Trap? Also, it looks like it does only up to 4 thousand or something. Is that enough?
 
@Insilico as it happens i wrote such two weeks ago in an example program. like void invert( bool& b ) { b = !b; }. it's more clear when the actual argument name is longer, i think
 
@Insilico Mmm. I think stuff like InvertBool() comes up fairly often in generic/template-metaprogramming situations. Well, not 'out in the open' but under the covers, inlining, yes
 
@sehe: Yeah, but those are pretty niche situations
 
@sehe Just NOT the boolean value solve that inlining?
 
10:45 PM
@CheersandhthAlf I'd always prefer toggle over invert since invert implies b = ~b to me
 
Or invert_bits
 
@sehe I think they are symonyms.
 
That's even clearer than just invert
 
For bools, ~b and !b are the same.
 
@Insilico Check your preprocessed sources and we'll speak again. If the compiler triggers on it, you'll not be happy about it making your code slower :)
 
10:46 PM
I think I need to rethink my design. It feels so horrible. ideone.com/1iVeG
 
@CatPlusPlus why did I read this as "For boobs, ..." ?
 
@sehe: Of course I wouldn't actually want to use a compiler that intentionally unoptimizes things like InvertBool() in TDWTF article. :-)
 
@CatPlusPlus well you got me, for bools, okay :) I'd still prefer toggle because the name tells me it is acting on bools as bools. I'd expect invert to take any integral type
 
!some_bool looks more familiar to me. ~some_bool looks rather strange, I won't use it. Unless you want to troll C++ noobs, of course.
 
:3201645 toggle sounds like a switch, where you can repeatedly invert on and off all day long.
 
10:48 PM
@tom_mai78101 Which, incidentally, you can.
 
Go ask on English.SE and see what they have to say about it
 
And on that note, I bid you farewell for the day.
 
@sehe Farewell, for the cup of tea, m'lad.
 
btw, there is not some_bool
 
@Andre As Mooing Duck said, no, that doesn't include smart pointers. Just naked pointers.
 
10:52 PM
Naked pointers are still useful in trees, though (to point to the parent, which is guaranteed to outlive any children it has).
Or maybe a reference is better…
 
@daknok_t Indeed: If A outlives B, B may store a reference to A.
Anyway, at the heart of the implementation of a container, you may certainly use naked pointers. But that should be a rare and very specific activity.
 
Perhaps a better way to say it is to not use pointers in application code
containers are something you make as part of a library, not an application
 
@Insilico no, there's definitely places for pointers
 
(I admit what's considered a library and what's considered an application is not all that well defined)
 
Other exceptions are kernel development and similar low-level things…
 
10:55 PM
Or here's a better one
 
bullshit. pointers are mutable references
 
"Don't use pointers when you don't have to"
 
...which are rarely needed.
 
@CatPlusPlus rarely, but occasionally.
 
Those words are pretty much synonyms.
 
10:56 PM
@CatPlusPlus they are really needed when they are needed
 
"Never use pointers unless you're willing to shoot yourself in the foot when it doesn't work"
 
@CatPlusPlus yeah pretty much
@Insilico pointers are fine if they don't own anything
 
Will you please stop throwing tautologies at me.
 
@Insilico plus function pointers
 
10:57 PM
@MooingDuck If you don't own, use a reference or reference wrapper
 
Function pointers suck.
 
Functors ftw.
 
@MooingDuck True, but if I see a pointer it's not immediately obvious what the hell I'm supposed to do with them (delete them, or not delete them?)
 
@Insilico Exactly. The big problem with naked pointers is that they have no self-describing semantics.
 
As evidenced by the many Qt questions that ask about "am I supposed to delete this QWidget*?"
 
10:58 PM
how can you iterate over something without pointer? write iterator object? with what? pointer?
 
@Abyx With a colon.
 
oc·ca·sion·al·ly
adv.
    Now and then; from time to time.
rare·ly
adv.
    1. Not often; infrequently
 
@CatPlusPlus Yay! English class.
 
"Don't use pointers. But if you have to, stick them in an class or something"
 
we don't have tail call in C++, so we need mutable variables
and we don't have maybe or nullable types too
 
10:59 PM
> Synonyms are different words with almost identical or similar meanings.
 
@Insilico non_owning_pointer?
 

« first day (538 days earlier)      last day (4408 days later) »