I defined this class:
template <class T>
class pure
{
public:
pure(T const& attr) {
this->attr = attr;
}
~pure() {}
T& operator=(T const& attr) {
return attr;
}
operator T() {
return this->attr;
}
private:
T attr;
};
This is a class that stores a value of type T
. When I want to use an instance of it, I get the attr
(by casting pure
to T
) instead of the instance (of pure
) itself.
My goal here is to make a class that can't be casted to any type other than the type of attr
, which is T
.