In C++ library headers, we'll sometimes see the following to improve legibility of the code inside a class:
template<typename MyExplicitelyLongTemplateParameter>
class C
{
public:
typedef MyExplicitelyLongTemplateParameter P;
// Use "P" and keep your sanity.
};
My question is, can one do the same with template template parameter?
template<template<typename> typename MyExplicitelyLongTemplateParameter>
class C
{
public:
typedef /* ??? */ P;
// Use "P" and keep your sanity.
};
In the current standard, you can't typedef a template. In the new, upcoming standard, you will be able to....
You can't create a typedef, no, but you can shorten the name:
template <template <typename> typename MyExplicitlyLongTemplateParameter>
class C
{
public:
template <typename T>
struct P
{
typedef MyExplicitlyLongTemplateParameter<T> Type;
};
// Use "P<T>::Type" and keep your sanity.
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With