Boost logo

Boost :

Subject: Re: [boost] [serialization] Passing literals to oarchive
From: Robert Ramey (ramey_at_[hidden])
Date: 2015-03-30 09:50:56


Bjorn Reese wrote
> 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;
> }

I meant that following won't compile

   template <typename T> void foo(const T& t) {}

   int main()
   {
     foo(42);
     return 0;
   }

I just tried to compile this and now I see I was wrong about this. I knew
that

   template <typename T> void foo( T & t) {}

   int main()
   {
     foo(42);
     return 0;
   }

doesn't compile. To me this always made sense since it doesn't make
much sense to take the address of something which is about to disappear
regardless of whether it's "const" or now. My fix was to use
void foo(T && t) which made sense to me - but of course not available
until now.

So make a trac ticket and I'll get around to addressing this.

Robert Ramey

--
View this message in context: http://boost.2283326.n4.nabble.com/serialization-Passing-literals-to-oarchive-tp4673832p4673909.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk