template class constructor error using gcc 11.2.0

33 Views Asked by At
template <class T>
class UserdataValue : public Userdata {
 private:
  UserdataValue<T>(UserdataValue<T> const&);
  UserdataValue<T> operator=(UserdataValue<T> const&);
};

when using gcc11.2.0 comiple, error reported: [enter image description here][1]

/home/user00/hxnextSvr2/dep/luabridge/detail/Userdata.h:247:36: error: expected ‘)’ before ‘const’ 247 | UserdataValue(UserdataValue const&); | ~ ^~~~~~ | ) [1]: https://i.stack.imgur.com/LhFbC.png

1

There are 1 best solutions below

0
OznOg On

You should not set the teplate parameter on the copy constructor

thus:

template <class T>
class UserdataValue : public Userdata {
 private:
  UserdataValue(UserdataValue<T> const&); // no template specification here
  UserdataValue<T> operator=(UserdataValue<T> const&);
};