Can someone explain me why I get compile errors with nvcc (cuda toolkit v9.2) when I include these template classes? It’s neither an issue for the visual studio compiler nor for gcc. But if I try to compile a .cu file with these template classes included, it does not work anymore.
template <typename IdxType = uint32>
class Idx
{
public:
constexpr explicit inline Idx();
explicit inline Idx(
const IdxType idx);
inline IdxType get() const;
inline void invalidate();
inline bool isInvalid() const;
inline operator IdxType() const;
inline const IdxType operator ()() const;
inline const Idx &operator ++();
inline const Idx operator ++(int);
inline void set(
const IdxType idx);
private:
IdxType mIdx;
};
template <typename IdxType = uint32>
class CameraIdx : private Idx<IdxType>
{
public:
explicit constexpr inline CameraIdx();
explicit inline CameraIdx(
const IdxType idx);
using Idx<IdxType>::get;
using Idx<IdxType>::invalidate;
using Idx<IdxType>::isInvalid;
using Idx<IdxType>::operator ();
using Idx<IdxType>::operator ++;
using Idx<IdxType>::operator IdxType;
using Idx<IdxType>::set;
};
template <typename IdxType = uint32>
class LidarIdx : private Idx<IdxType>
{
public:
explicit constexpr inline LidarIdx();
explicit inline LidarIdx(
const IdxType idx);
using Idx<IdxType>::get;
using Idx<IdxType>::invalidate;
using Idx<IdxType>::isInvalid;
using Idx<IdxType>::operator ();
using Idx<IdxType>::operator ++;
using Idx<IdxType>::operator IdxType;
using Idx<IdxType>::set;
};
template <typename IdxType = uint32>
class ViewIdx : private Idx<IdxType>
{
public:
explicit constexpr inline ViewIdx();
explicit inline ViewIdx(
const IdxType idx);
using Idx<IdxType>::get;
using Idx<IdxType>::invalidate;
using Idx<IdxType>::isInvalid;
using Idx<IdxType>::operator ();
using Idx<IdxType>::operator ++;
using Idx<IdxType>::operator IdxType;
using Idx<IdxType>::set;
inline const ViewIdx& operator +=(
const ViewIdx& rhs);
};
Here’s a part of the compiler output:
/home/samaroud/Repos/Recon/Reconstruction/Reconstruction/DataTypes.h:58:48: error: ‘_Tp’ does not name a type
using Idx::operator IdxType;
^
/home/samaroud/Repos/Recon/Reconstruction/Reconstruction/DataTypes.h:75:48: error: ‘_Tp’ does not name a type
using Idx::operator IdxType;
^
/home/samaroud/Repos/Recon/Reconstruction/Reconstruction/DataTypes.h:92:48: error: ‘_Tp’ does not name a type
using Idx::operator IdxType;
It seems like the template type parameter deduction does not work for the implicit cast operators.
_Tp should be uint32/unsigned int.