I have been modifying a class which contains an STL container into a template so that an allocator can be passed in.
This goes as follows:
class Foo
{
public:
struct Bar
{
// stuff
};
using Container = std::vector< Bar >;
private:
Container contents;
};
Becomes:
template<
template <typename T> typename ALLOCATOR = std::allocator
>
class Foo
{
public:
struct Bar
{
// stuff
};
using Allocator = ALLOCATOR<Bar>;
using Container = std::vector< Bar, Allocator >;
private:
Container contents;
};
This works great on all of the platforms I have to support except one. RHEL7 uses gcc 4.8 by default and use of typename
in template type parameters seems to have been added by n4051 in gcc 5 according to this table.
How can this be done for older compilers?
Also I note this is a C++17 feature. How would these parameters be written in C++14 or earlier?