Vicente J. Botet Escriba | 18 Jul 2012 23:15
Picon

[TypeErasure] assignment operator of any references

Hi,

The References section constains this example:

int  i,  j;
any<typeid_<>,  _self&>  x(i),  y(j);
x  =  y;  // error

The following basic c++ code

int i=1, j=0;
int& x(i);
int& y(j);
x = y; // [1]

works and the expected value of x after [1] is 0.

Which concept requirements should I add to make the following work? 
assignable?

int  i,  j;
any<mpl::vector<typeid_<>, ...>,  _self&>  x(i),  y(j);
x  =  y;  // no error

Best,
Vicente

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

(Continue reading)

Steven Watanabe | 18 Jul 2012 23:49
Picon

Re: [TypeErasure] assignment operator of any references

AMDG

On 07/18/2012 02:15 PM, Vicente J. Botet Escriba wrote:
> Hi,
> 
> The References section constains this example:
> 
> int  i,  j;
> any<typeid_<>,  _self&>  x(i),  y(j);
> x  =  y;  // error
> 
> The following basic c++ code
> 
> int i=1, j=0;
> int& x(i);
> int& y(j);
> x = y; // [1]
> 
> works and the expected value of x after [1] is 0.
> 
> Which concept requirements should I add to make the following work?
> assignable?
> 

Yes.  assignable<> should work.

> int  i,  j;
> any<mpl::vector<typeid_<>, ...>,  _self&>  x(i),  y(j);
> x  =  y;  // no error
> 
(Continue reading)

Vicente J. Botet Escriba | 19 Jul 2012 07:10
Picon

Re: [TypeErasure] assignment operator of any references

Le 18/07/12 23:49, Steven Watanabe a écrit :
> AMDG
>
> On 07/18/2012 02:15 PM, Vicente J. Botet Escriba wrote:
>> Hi,
>>
>> The References section constains this example:
>>
>> int  i,  j;
>> any<typeid_<>,  _self&>  x(i),  y(j);
>> x  =  y;  // error
>>
>> The following basic c++ code
>>
>> int i=1, j=0;
>> int& x(i);
>> int& y(j);
>> x = y; // [1]
>>
>> works and the expected value of x after [1] is 0.
>>
>> Which concept requirements should I add to make the following work?
>> assignable?
>>
> Yes.  assignable<> should work.
>
>> int  i,  j;
>> any<mpl::vector<typeid_<>, ...>,  _self&>  x(i),  y(j);
>> x  =  y;  // no error
>>
(Continue reading)

Steven Watanabe | 19 Jul 2012 07:50
Picon

Re: [TypeErasure] assignment operator of any references

AMDG

On 07/18/2012 10:10 PM, Vicente J. Botet Escriba wrote:
> 
> Does it mean that the sentence in section "Using References"
> 
> " References are not assignable. Just like a built-in C++ reference,
> once you've initialized it you can't change it to point to something else"
> 
> could be subject to confusion. What do you exactly wanted to show there?
> 

Good point.  What I meant to show was that
you can't rebind a reference to point to
a different object.  I'll clarify this.

In Christ,
Steven Watanabe

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Gmane