[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C++11/14
From: |
Hans Aberg |
Subject: |
Re: C++11/14 |
Date: |
Tue, 20 Jan 2015 18:29:55 +0100 |
> On 20 Jan 2015, at 09:57, Akim Demaille <address@hidden> wrote:
>
>
>> Le 19 janv. 2015 à 23:14, Hans Aberg <address@hidden> a écrit :
>>
>>
>>> On 19 Jan 2015, at 18:35, Akim Demaille <address@hidden> wrote:
>>>
>>>> Le 19 janv. 2015 à 14:28, Hans Aberg <address@hidden> 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!
Just for the record, I was able to fix the combined r- and r-value template:
template <typename T>
variant (T&& t)
: yytypeid_ (&typeid (T))
{
YYASSERT (sizeof (T) <= S);
typedef std::remove_reference_t<T> T1;
new (yyas_<T1> ()) T1 (std::forward<T>(t));
}
One then has to add
template <typename T>
T*
yyas_ () &
{
void *yyp = yybuffer_.yyraw;
return static_cast<T*> (yyp);
}
And in addition l-value calls:
basic_symbol (typename Base::kind_type t, const Int& v, const location_type&
l);
basic_symbol (typename Base::kind_type t, Int& v, const location_type& l);
basic_symbol (typename Base::kind_type t, Int&& v, const location_type& l);
static inline
symbol_type
make_NUMBER (const Int& v, const location_type& l);
static inline
symbol_type
make_NUMBER (Int& v, const location_type& l);
static inline
symbol_type
make_NUMBER (Int&& v, const location_type& l);
template <typename Base>
calcxx_parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t,
const Int& v, const location_type& l)
: Base (t)
, value (v)
, location (l)
{}
template <typename Base>
calcxx_parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t,
Int& v, const location_type& l)
: Base (t)
, value (v)
, location (l)
{}
template <typename Base>
calcxx_parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t,
Int&& v, const location_type& l)
: Base (t)
, value (std::move(v))
, location (l)
{}
calcxx_parser::symbol_type
calcxx_parser::make_NUMBER (const Int& v, const location_type& l)
{
return symbol_type (token::TOK_NUMBER, v, l);
}
calcxx_parser::symbol_type
calcxx_parser::make_NUMBER (Int& v, const location_type& l)
{
return symbol_type (token::TOK_NUMBER, v, l);
}
calcxx_parser::symbol_type
calcxx_parser::make_NUMBER (Int&& v, const location_type& l)
{
return symbol_type (token::TOK_NUMBER, std::move(v), l);
}
- Re: C++11/14, (continued)
- Re: C++11/14, Akim Demaille, 2015/01/19
- Re: C++11/14, Hans Aberg, 2015/01/19
- Re: C++11/14, Akim Demaille, 2015/01/19
- Re: C++11/14, Hans Aberg, 2015/01/19
- Re: C++11/14, Akim Demaille, 2015/01/19
- Re: C++11/14, Hans Aberg, 2015/01/19
- Re: C++11/14, Hans Aberg, 2015/01/19
- Re: C++11/14, Akim Demaille, 2015/01/20
- Re: C++11/14, Hans Aberg, 2015/01/20
- Re: C++11/14, Hans Aberg, 2015/01/20
- Re: C++11/14,
Hans Aberg <=
- Re: C++11/14, Hans Aberg, 2015/01/19