pcg-cpp icon indicating copy to clipboard operation
pcg-cpp copied to clipboard

Fix {i,o}stream support for pcg128_t

Open ahh opened this issue 8 years ago • 2 comments

We defined operator{<<,>>} for pcg128_t in pcg_extras, assuming Koenig lookup would find these as needed. This isn't actually true, because pcg128_t is a typedef, and Koenig lookup doesn't apply to the namespaces of typedefs. We would need to define those operators in the global namespace; that's a bad idea.

Instead, work around it. Define explicit Input and Output functions in the namespace, which in turn default to operator<< and operator>> if they need to, and explicitly use them in engine printing/parsing functions.

ahh avatar Jun 26 '17 19:06 ahh

Note that I do not intend for this to merged as-is; it's incomplete (I need to do the same thing for uint8 handling and for extended-generator printing. Figured I'd demonstrate what the approach looks like and see if we can come to a consensus before I wrote out all the details.

Thoughts?

ahh avatar Jun 26 '17 19:06 ahh

I would love for this to be merged (I would like checkpointing with pcg64). @imneme would you be happy to merge this code, if @ahh completes it?

It is of course unfortunate not to be able to use operator<< and operator>> but since this only affects a small amount of code, the proposed solution is perfectly adequate in my opinion.

dhardy avatar Jul 02 '19 16:07 dhardy