To do this, you can use pre-C ++ 11 “typedef workaround pattern”, which does not include #defining type names, but makes the syntax for using this type more ugly:
#ifdef MY_TOOLSET_HAS_STD_ARRAY #include <array> #else #include <boost/array.hpp> #endif template <typename T, size_t N> struct fixed_array { #ifdef MY_TOOLSET_HAS_STD_ARRAY typedef std::array<T, N> type; #else typedef boost::array<T, N> type; #endif };
Then your use of the type will be:
typename fixed_array<char, 4>::type some_chars;
However, it would be much easier to use boost::array . This means that you need to test fewer permutations and therefore reduce code-based maintenance costs.
source share