vectorwrapper/test/unit_noconv/sample_vector.hpp
King_DuckZ db7b9becd5 Let users specify a wrapping namespace.
This is useful when vwr is used and publicly exposed in a
library. If both the library and the standalone project depend
on vwr, this change gives the user the opportunity to keep the
two usages separate. This is especially important if both the
library and the standalone program happen to specialize the
Info template for the same type.
2017-03-04 00:04:40 +00:00

34 lines
1,008 B
C++

#ifndef idD52B2591EB8240A980C5B3823D025EC1
#define idD52B2591EB8240A980C5B3823D025EC1
#include "vectorwrapper/vectorwrapper.hpp"
#include <array>
#define SPECIALIZE_ARRAY_VECTOR(TYPE, DIM) \
template <> \
struct VectorWrapperInfo<std::array<TYPE, DIM>> { \
enum { dimensions = DIM }; \
typedef TYPE scalar_type; \
typedef std::array<scalar_type, dimensions> vector_type; \
static scalar_type& get_at (size_t parIndex, vector_type& parVector) { \
return parVector[parIndex]; \
} \
}
namespace vwr_outer_ns {
namespace vwr {
SPECIALIZE_ARRAY_VECTOR(float, 2);
SPECIALIZE_ARRAY_VECTOR(float, 3);
SPECIALIZE_ARRAY_VECTOR(short int, 2);
SPECIALIZE_ARRAY_VECTOR(short int, 3);
typedef Vec<std::array<float, 2>> float2;
typedef Vec<std::array<float, 3>> float3;
typedef Vec<std::array<short int, 2>> short2;
typedef Vec<std::array<short int, 3>> short3;
} //namespace vwr
} //namespace vwr_outer_ns
#undef SPECIALIZE_ARRAY_VECTOR
#endif