I can't see anything technically wrong and it compiles fine with current
Visual C++ and g++.
Not what you're asking but note that
* `typedef` is old C syntax, modern `using` can be more clear.
* `const` at namespace scope implies `static`, i.e. no need to repeat.
* `array_of_2` won't work for T that's not default constructible.
Here's re-styling of the code with the above 3 points addressed:
#pragma once
#include <limits> // std::numeric_limits
#include <utility> // std::move
#include <cstddef> // std::(size_t, ptrdiff_t)
namespace fem {
using std::numeric_limits,
std::move;
using size_t = std::size_t;
using ssize_t = std::ptrdiff_t;
template< class Type >
constexpr Type max_ = numeric_limits<Type>::max();
constexpr size_t size_t_max = max_<size_t>;
constexpr ssize_t ssize_t_max = max_<ssize_t>;
template< class T >
struct array_of_2_
{
T elems[2];
array_of_2_() {}
array_of_2_( T a, T b ): elems{ move( a ), move( b ) } {}
};
using size_t_2 = array_of_2_<size_t> ;
using ssize_t_2 = array_of_2_<ssize_t> ;
} // namespace fem
- Alf