Boost logo

Boost :

Subject: Re: [boost] [type_traits] common_type and SFINAE
From: Matt Calabrese (rivorus_at_[hidden])
Date: 2012-10-05 14:36:36


On Fri, Oct 5, 2012 at 2:08 PM, Lorenzo Caminiti <lorcaminiti_at_[hidden]>wrote:

> Hello all,
>
> One a separate note, why the following SFINAE impl of
> EqualityComparable returns 0 on std::common_type<int, int>::type?
>
> EqualityComparable<int>::value // 1 -- ok
> EqualityComparable<std::common_type<int>::type>::value // 1 -- ok
>
> EqualityComparable<std::common_type<int, int>::type>::value // 0 --
> why??

common_type< int, int >::type would be int&&. In your EqualityComparable
implementation, your function parameter types are the argument of
EqualityComparable directly, which is an r-value reference type. In your
explicit call to check<_1>, you are passing "a" and "b" directly, but the
parameter types of check expect r-value references. In order for this to
work, you'd need to use std::forward.

-- 
-Matt Calabrese

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