Re: [Boost-bugs] [Boost C++ Libraries] #11897: Compile failure in type_traits_detail::mp_valid_impl with CUDA 7.0

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #11897: Compile failure in type_traits_detail::mp_valid_impl with CUDA 7.0
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-01-08 14:50:20


#11897: Compile failure in type_traits_detail::mp_valid_impl with CUDA 7.0
-------------------------------+-------------------------
  Reporter: a.grund@… | Owner: johnmaddock
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: type_traits
   Version: Boost 1.60.0 | Severity: Showstopper
Resolution: | Keywords:
-------------------------------+-------------------------

Comment (by Alex Grund <a.grund@…>):

 This bug was introduced in 1.60. 1.59 is working fine.
 As the following code shows, the problem is related to variadic templates:


 {{{
 #include <type_traits>

 template<template<class...> class F, class... T>
 struct mp_valid_impl
 {
     template<template<class...> class G, class = G<T...>>
     static int check(int);

     template<template<class...> class>
     static bool check(...);

     using type = decltype(check<F>(0));
 };

 template<template<class...> class F, class T>
 struct mp_valid_impl2
 {
     template<template<class...> class G, class = G<T>>
     static int check(int);

     template<template<class...> class>
     static bool check(...);

     using type = decltype(check<F>(0));
 };

 template<template<class> class F, class T>
 struct mp_valid_impl3
 {
     template<template<class> class G, class = G<T>>
     static int check(int);

     template<template<class> class>
     static bool check(...);

     using type = decltype(check<F>(0));
 };


 template<typename T>
 struct MetaFunc{};

 int main(){
     typename mp_valid_impl<MetaFunc, int>::type i;
     typename mp_valid_impl2<MetaFunc, int>::type i2;
     typename mp_valid_impl3<MetaFunc, int>::type i3;
 }
 }}}

 Output:


 {{{
 BoostMpValid.cu(12): error: no instance of overloaded function
 "mp_valid_impl<F, T...>::check [with F=MetaFunc, T=<int>]" matches the
 argument list
             argument types are: (int)
           detected during instantiation of class "mp_valid_impl<F, T...>
 [with F=MetaFunc, T=<int>]"
 (44): here

 BoostMpValid.cu(24): error: no instance of overloaded function
 "mp_valid_impl2<F, T>::check [with F=MetaFunc, T=int]" matches the
 argument list
             argument types are: (int)
           detected during instantiation of class "mp_valid_impl2<F, T>
 [with F=MetaFunc, T=int]"
 (45): here

 BoostMpValid.cu(46): warning: variable "i3" was declared but never
 referenced
 }}}


 So only the non-variadic version works. A simple workaround is probably to
 deactivate variadic templates by defining
 BOOST_NO_CXX11_VARIADIC_TEMPLATES for nvcc < 7.5. 7.5 is working so this
 can be used there.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11897#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC