Is it possible to define such type alias with using
keyword in c++?
How would be the syntax? I have tried using const_type = typename const T::type
it doesn’t work.
template <typename T>
class DoubleBuffer {
typedef T value_type;
typedef T& reference;
typedef T const & const_reference;
typedef T* pointer;
const_reference operator[](const size_t pos){
...
}
};
template <typename T>
class DoubleBuffer {
public:
using value_type = T;
using reference = T&;
using const_reference = T const &;
using const_type = const typename T::type;
using pointer = T*;
//...
};
Or:
template <typename T>
class DoubleBuffer {
public:
using value_type = T;
using reference = T&;
using const_reference = T const &;
using const_type = const T;
using pointer = T*;
//...
};
Depending on what T
actually is - a struct
/class
with a nested type
defined, or a standalone type.