Boost logo

Boost :

Subject: Re: [boost] [typeof] deducing type at class level
From: Jeroen Habraken (vexocide_at_[hidden])
Date: 2011-06-22 12:42:20


On 22 June 2011 18:18, Mathias Gaunard <mathias.gaunard_at_[hidden]> wrote:
> On 22/06/2011 18:02, lcaminiti wrote:
>>
>> Hello all,
>>
>> Is there any way to use BOOST_TYPEOF at class level? For example:
>>
>> struct vect {
>>     size_t size();
>>
>>     typedef BOOST_TYPEOF(size()) size_type; // can I make this work
>> somehow?
>
> typedef BOOST_TYPEOF(make<vect>().size()) size_type;
>
> with
>
> #ifndef BOOST_NO_RVALUE_REFERENCES
>
> template<class T>
> typename enable_if<
>   is_reference<T>,
>   T
>>::type
> make();
>
> template<class T>
> typename disable_if<
>   is_reference<T>,
>   T&
>>::type
> make();
>
> #else
>
> T&& make();
>
> #endif

This can be done using boost::type_traits::add_reference I believe:

template <class T>
typename add_reference<T>::type make();

Jeroen


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