> On 20 Jan 2015, at 09:57, Akim Demaille <[email protected]> wrote:
>
>
>> Le 19 janv. 2015 à 23:14, Hans Aberg <[email protected]> a écrit :
>>
>>
>>> On 19 Jan 2015, at 18:35, Akim Demaille <[email protected]> wrote:
>>>
>>>> Le 19 janv. 2015 à 14:28, Hans Aberg <[email protected]> a écrit :
>>>>
>>>> So it may suffice to have move constructors in the class variant.
>>>
>>> Right. With #if around them :)
>>
>> I succeeded in replacing all copying with move operations in the calc++
>> example!
>
> That's good news, thanks for the experimentation!
Some more inputs:
The variants class might work with both r- and l-values by something like
template <typename T>
variant (T&& t)
: yytypeid_ (&typeid (T))
{
YYASSERT (sizeof (T) <= S);
new (yyas_<T> ()) T (std::forward(t));
}
but it requires a bit work when T becomes a reference type.
And since you already store a type_info pointer, it should be possible to do
dynamic lookups by adding say a std::unordered_map<> with dynamic_cast pointers.