The non-C++11 implemention of POLYVOX_STATIC_ASSERT is no longer dependent on Boost.
This commit is contained in:
parent
cc0b3ae2c0
commit
64cd6e31b0
@ -69,4 +69,27 @@ freely, subject to the following restrictions:
|
||||
|
||||
#endif
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
#if defined(HAS_CXX11_STATIC_ASSERT)
|
||||
//In this case we can just use static_assert
|
||||
#define POLYVOX_STATIC_ASSERT static_assert
|
||||
#else
|
||||
// empty default template
|
||||
template <bool b>
|
||||
struct StaticAssert {};
|
||||
|
||||
// template specialized on true
|
||||
template <>
|
||||
struct StaticAssert<true>
|
||||
{
|
||||
// If the static assertion is failing then this function won't exist. It will then
|
||||
// appear in the error message which gives a clue to the user about what is wrong.
|
||||
static void ERROR_The_static_assertion_has_failed() {}
|
||||
};
|
||||
|
||||
#define POLYVOX_STATIC_ASSERT(condition, message) StaticAssert<(condition)>::ERROR_The_static_assertion_has_failed();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif //__PolyVox_ErrorHandling_H__
|
||||
|
@ -98,13 +98,6 @@ freely, subject to the following restrictions:
|
||||
#define polyvox_constexpr
|
||||
#endif
|
||||
|
||||
#if defined(HAS_CXX11_STATIC_ASSERT)
|
||||
//In this case we can just use static_assert
|
||||
#else
|
||||
#include <boost/static_assert.hpp>
|
||||
#define static_assert(condition, message) BOOST_STATIC_ASSERT(condition)
|
||||
#endif
|
||||
|
||||
#if defined(HAS_CXX11_CSTDINT_H)
|
||||
#include <cstdint>
|
||||
#else
|
||||
|
@ -53,7 +53,7 @@ namespace PolyVox
|
||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y)
|
||||
{
|
||||
static_assert(Size == 2, "This constructor should only be used for vectors with two elements.");
|
||||
POLYVOX_STATIC_ASSERT(Size == 2, "This constructor should only be used for vectors with two elements.");
|
||||
|
||||
m_tElements[0] = x;
|
||||
m_tElements[1] = y;
|
||||
@ -68,7 +68,7 @@ namespace PolyVox
|
||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y, StorageType z)
|
||||
{
|
||||
static_assert(Size == 3, "This constructor should only be used for vectors with three elements.");
|
||||
POLYVOX_STATIC_ASSERT(Size == 3, "This constructor should only be used for vectors with three elements.");
|
||||
|
||||
m_tElements[0] = x;
|
||||
m_tElements[1] = y;
|
||||
@ -86,7 +86,7 @@ namespace PolyVox
|
||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y, StorageType z, StorageType w)
|
||||
{
|
||||
static_assert(Size == 4, "This constructor should only be used for vectors with four elements.");
|
||||
POLYVOX_STATIC_ASSERT(Size == 4, "This constructor should only be used for vectors with four elements.");
|
||||
|
||||
m_tElements[0] = x;
|
||||
m_tElements[1] = y;
|
||||
@ -129,14 +129,14 @@ namespace PolyVox
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
Vector<Size, StorageType, OperationType>::~Vector(void)
|
||||
{
|
||||
// We put the static_asserts in the destructor because there is one one of these,
|
||||
// We put the static asserts in the destructor because there is one one of these,
|
||||
// where as there are multiple constructors.
|
||||
|
||||
// Force a vector to have a length greater than one. There is no need for a
|
||||
// vector with one element, and supporting this would cause confusion over the
|
||||
// behaviour of the constructor taking a single value, as this fills all elements
|
||||
// to that value rather than just the first one.
|
||||
static_assert(Size > 1, "Vector must have a length greater than one.");
|
||||
POLYVOX_STATIC_ASSERT(Size > 1, "Vector must have a length greater than one.");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -442,7 +442,7 @@ namespace PolyVox
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
inline StorageType Vector<Size, StorageType, OperationType>::getZ(void) const
|
||||
{
|
||||
static_assert(Size >= 3, "You can only get the 'z' component from a vector with at least three elements.");
|
||||
POLYVOX_STATIC_ASSERT(Size >= 3, "You can only get the 'z' component from a vector with at least three elements.");
|
||||
|
||||
return m_tElements[2];
|
||||
}
|
||||
@ -453,7 +453,7 @@ namespace PolyVox
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
inline StorageType Vector<Size, StorageType, OperationType>::getW(void) const
|
||||
{
|
||||
static_assert(Size >= 4, "You can only get the 'w' component from a vector with at least four elements.");
|
||||
POLYVOX_STATIC_ASSERT(Size >= 4, "You can only get the 'w' component from a vector with at least four elements.");
|
||||
|
||||
return m_tElements[3];
|
||||
}
|
||||
@ -491,7 +491,7 @@ namespace PolyVox
|
||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y, StorageType z)
|
||||
{
|
||||
static_assert(Size >= 3, "You can only use this version of setElements() on a vector with at least three elements.");
|
||||
POLYVOX_STATIC_ASSERT(Size >= 3, "You can only use this version of setElements() on a vector with at least three elements.");
|
||||
|
||||
m_tElements[0] = x;
|
||||
m_tElements[1] = y;
|
||||
@ -508,7 +508,7 @@ namespace PolyVox
|
||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y, StorageType z, StorageType w)
|
||||
{
|
||||
static_assert(Size >= 4, "You can only use this version of setElements() on a vector with at least four elements.");
|
||||
POLYVOX_STATIC_ASSERT(Size >= 4, "You can only use this version of setElements() on a vector with at least four elements.");
|
||||
|
||||
m_tElements[0] = x;
|
||||
m_tElements[1] = y;
|
||||
@ -540,7 +540,7 @@ namespace PolyVox
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
inline void Vector<Size, StorageType, OperationType>::setZ(StorageType tZ)
|
||||
{
|
||||
static_assert(Size >= 3, "You can only set the 'w' component from a vector with at least three elements.");
|
||||
POLYVOX_STATIC_ASSERT(Size >= 3, "You can only set the 'w' component from a vector with at least three elements.");
|
||||
|
||||
m_tElements[2] = tZ;
|
||||
}
|
||||
@ -551,7 +551,7 @@ namespace PolyVox
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
inline void Vector<Size, StorageType, OperationType>::setW(StorageType tW)
|
||||
{
|
||||
static_assert(Size >= 4, "You can only set the 'w' component from a vector with at least four elements.");
|
||||
POLYVOX_STATIC_ASSERT(Size >= 4, "You can only set the 'w' component from a vector with at least four elements.");
|
||||
|
||||
m_tElements[3] = tW;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user