On 03/29/2015 05:35 PM, Robert Ramey wrote:
Bjorn Reese wrote
On 03/27/2015 05:49 PM, Robert Ramey wrote:
In this case the problem is different. A parameter value placed on the stack cannot be passed by "const T & t". This syntax assumes and enforces
Why not?
It generates a compile time error when you pass an rvalue.
I am not sure I follow you. Are you saying that the following does not compile? template <typename T> void foo(const T& t) {} int main() { foo(42); int x = 42; foo(x); return 0; }
Since I wrote this, I've been considering it. I looked at your patch. I would likely condition it on the type being a tracked or untracked type rather than being on a primitive type.
That is perfectly fine with me.
the reason I would think that it's not a common case is the following:
The unit-tests for my own output archives checks that the encoding is correct by feeding literal values into the archive. If I could pass literal values to an oarchive, then it would look like this: archive << 1 << 0x0100 << 0x010000 << 0x0100000000LL; followed by a check to verify that the archive has generated to correct output. However, currently I have to specify temporary variables (with odd names) for the literal values, which leads to code like this: int alpha = 1; int bravo = 0x0100; int charlie = 0x010000; long long delta = 0x0100000000LL; archive << alpha << bravo << charlie << delta; I have plenty of the above workarounds in my unit-tests.
ar >> ?; // what do we do with the result we're retrieving?
That is not what I am asking for, but you compare and skip the literal values like iostream does.