Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2003-09-15 13:58:05


On Sep 15, 2003, at 1:37 PM, Eric Friedman wrote:

> Howard Hinnant wrote:
>> Like Daniel, I recommend the enable_if pattern here, but I would do it
>> like:
>>
>> struct test_t
>> {
>> template <typename T>
>> test_t(T&, typename enable_if<!is_const<T>::value>::type* = 0)
>> {
>> }
>>
>> template <typename T>
>> test_t(T&, typename enable_if<is_const<T>::value>::type* = 0)
>> {
>> }
>> }
>
> Unfortunately, this prevents construction from temporaries.

Hmm... How does this look?

struct test_t
{
     template <typename T>
     test_t(T&, typename enable_if<!is_const<T>::value>::type* = 0)
     {
     }

     template <typename T>
     test_t(T&, typename enable_if<is_const<T>::value>::type* = 0)
     {
     }

     template <typename T>
     test_t(T)
     {
     }
};

-Howard


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