I have the below code where std::tuple works with nullptr but not with NULL.
#include <iostream>
#include <tuple>
int main()
{
tuple<int*> t1, t2;
t1 = std::make_tuple(NULL);
t2 = std::make_tuple(nullptr);
}
When compiled with C++11, the code works when nullptr is used, but it gives the below error where NULL is used.
In file included from tuple.cpp:2:
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/tuple:447:8: error: assigning to 'int *' from incompatible type 'long'
= std::forward<_UHead>(_Tuple_impl<_Idx, _UHead>::_M_head(__in));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/tuple:575:36: note: in instantiation of function template specialization 'std::_Tuple_impl<0, int *>::operator=<long>' requested here
static_cast<_Inherited&>(*this) = std::move(__in);
^
tuple.cpp:13:8: note: in instantiation of function template specialization 'std::tuple<int *>::operator=<long, void>' requested here
t1 = std::make_tuple(NULL);
^
1 error generated.
Here, the type of NULL is long int and the tuple is strict enough and doesn't accept it.
How can we make it work using NULL as well, as our client says it works when used with nvcc compiler (when they use the above snippet in the CUDA code), but its not working otherwise.