For example I have code like:
template<typename A, typename B>
using Map = std::map<A, B>;
template<typename A, typename B>
using UnorderedMap = std::unordered_map<A, B>;
I would like to do the same thing for std::array
, i.e:
template<typename A, typename B>
using Array = std::array<A, B>;
But if I do this, I will get a compiler error:
error C2993: 'B': illegal type for non-type template parameter '_Size'
error C2955: 'std::array': use of class template requires template
argument list array(21): message : see declaration of 'std::array'
Is there any way to declare an Array
that would in the background be using the std::array
?
In the end I want to use arrays like Array<int, 7> items
instead of std::array<int, 7> items
.
The 2nd template parameter of std::array
is a non-type template parameter with type std::size_t
. It should be
template<typename A, std::size_t B>
using Array = std::array<A, B>;