functional and type_traits cleanup

François Dumont
Fri Apr 5 20:13:00 GMT 2013

On 04/05/2013 12:20 AM, Jonathan Wakely wrote:
> On 4 April 2013 21:16, François Dumont wrote:
> I think this is mostly very good, thanks for cleaning it up. The 
> indentiation of the closing brace for __is_assignable_helper looks 
> wrong. Is there a reason that __is_assignable_helper::__test uses a 
> default template argument but __is_convertible_helper::__test uses 
> decltype(expr, type) in the function return type? I think the 
> decltype(__test_aux<_Tp1>(...)) expression would work as a default 
> template argument too, which I find easier to read because it doesn't 
> clutter up the return type. 

In fact my first attempt was a very simple one:

   template<typename _From, typename _To>
     class __is_convertible_helper<_From, _To, false>
       template<typename _To1>
     static true_type

     static false_type

       typedef decltype(__test<_To>(std::declval<_From>())) type;

But some tests failed like:
In file included from 
In instantiation of 'struct std::__is_convertible_helper<const 
std::tuple<std::_Placeholder<1> >&, std::_Placeholder<1>, false>':
required from 'struct std::is_convertible<const 
std::tuple<std::_Placeholder<1> >&, std::_Placeholder<1> >'
required from 'struct std::__and_<std::is_convertible<const 
std::tuple<std::_Placeholder<1> >&, std::_Placeholder<1> > >'
required from 'struct std::_Bind<void (*(std::_Placeholder<1>))(int)>'
/home/fdt/dev/gcc/src/libstdc++-v3/testsuite/20_util/bind/ required 
from here
error: 'std::_Placeholder<1>' is an inaccessible base of 
'std::tuple<std::_Placeholder<1> >'
        typedef decltype(__test<_To>(std::declval<_From>())) type;
error:   initializing argument 1 of 'static std::true_type 
std::__is_convertible_helper<_From, _To, false>::__test(_To1) [with _To1 
= std::_Placeholder<1>; _From = const std::tuple<std::_Placeholder<1> 
 >&; _To = std::_Placeholder<1>; std::true_type = 
std::integral_constant<bool, true>]'

 From my point of view this is an other example of use case for which 
gcc is not SFINAE friendly enough, no ?

But the version with the default template parameter is fine and more 
consistent with the other helpers implementation so, adopted! Here is an 
other version of the patch for validation.

     Daniel, I agree that inheritance with integral_constant is not as 
obvious as before but it is still there and it is just what the compiler 
need. I even hope that it also simplified a (very) little bit the job 
for the compiler.

Ok to commit ?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: cleanup.patch
Type: text/x-patch
Size: 14515 bytes
Desc: not available
URL: <>

More information about the Libstdc++ mailing list