The following code (originally from Boost) fails to compile using nvcc 7.0 with C++11 support enabled:
#include <memory>
template<typename T>
struct result_of_always_void
{
typedef void type;
};
template<typename F, typename Enable = void> struct cpp0x_result_of_impl {};
template<typename F,typename T0>
struct cpp0x_result_of_impl<F(T0), typename result_of_always_void< decltype(std::declval<F>()(std::declval<T0 >()))>::type >
{
typedef decltype(std::declval<F>()(std::declval<T0 >())) type;
};
int main ()
{
return 0;
}
The error I get is the following:
test.cu:16:93: error: invalid use of qualified-name ‘std::allocator_traits<_Alloc>::propagate_on_container_swap’
typedef decltype(std::declval<F>()(std::declval<T0 >())) type;
^
I suspect this is due to a bug in the nvcc compiler, but before I file a bug, I wanted to ask if it is possible to simplify the code further while still having it produce the error?
The issue appears to be fixed in cuda 7.5RC. Please switch to the newer cuda version.
$ cat t877.cu
#include <memory>
template<typename T>
struct result_of_always_void
{
typedef void type;
};
template<typename F, typename Enable = void> struct cpp0x_result_of_impl {};
template<typename F,typename T0>
struct cpp0x_result_of_impl<F(T0), typename result_of_always_void< decltype(std::declval<F>()(std::declval<T0 >()))>::type >
{
typedef decltype(std::declval<F>()(std::declval<T0 >())) type;
};
int main ()
{
return 0;
}
$ /usr/local/cuda-7.0/bin/nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2015 NVIDIA Corporation
Built on Mon_Feb_16_22:59:02_CST_2015
Cuda compilation tools, release 7.0, V7.0.27
$ /usr/local/cuda-7.0/bin/nvcc -std=c++11 t877.cu -o t877
t877.cu:14:93: error: invalid use of qualified-name âstd::allocator_traits<_Alloc>::propagate_on_container_swapâ
typedef decltype(std::declval<F>()(std::declval<T0 >())) type;
^
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2015 NVIDIA Corporation
Built on Thu_May__7_00:35:41_CDT_2015
Cuda compilation tools, release 7.5, V7.5.6
$ nvcc -std=c++11 t877.cu -o t877
$
You're welcome to file a bug, of course.