Fixed conflict with Boost, ticket #158

This commit is contained in:
Christophe Riccio 2012-01-08 13:13:18 +00:00
parent c7d752cdf8
commit 040ea3ce7e
4 changed files with 30 additions and 17 deletions

View File

@ -87,29 +87,32 @@ namespace glm
VECTORIZE_VEC(exp2) VECTORIZE_VEC(exp2)
namespace detail namespace _detail
{ {
template <int PATH = float_or_int_value::GLM_ERROR> template <int _PATH = detail::float_or_int_value::GLM_ERROR>
struct compute_log2 struct _compute_log2
{ {
template <typename T> template <typename T>
T operator() (T const & Value) const T operator() (T const & Value) const;
/*
{ {
GLM_STATIC_ASSERT(0, "'log2' parameter has an invalid template parameter type. GLM core features only supports floating-point types, include <glm/gtx/integer.hpp> for integer types support. Others types are not supported."); GLM_STATIC_ASSERT(0, "'log2' parameter has an invalid template parameter type. GLM core features only supports floating-point types, include <glm/gtx/integer.hpp> for integer types support. Others types are not supported.");
return Value; return Value;
} }
*/
}; };
template <> template <>
struct compute_log2<float_or_int_value::GLM_FLOAT> struct _compute_log2<detail::float_or_int_value::GLM_FLOAT>
{ {
template <typename T> template <typename T>
T operator() (T const & Value) const T operator() (T const & Value) const
{ {
return ::std::log(Value) / T(0.69314718055994530941723212145818); return T(::std::log(Value)) / T(0.69314718055994530941723212145818);
} }
}; };
}//namespace detail
}//namespace _detail
// log2, ln2 = 0.69314718055994530941723212145818f // log2, ln2 = 0.69314718055994530941723212145818f
template <typename genType> template <typename genType>
@ -119,7 +122,7 @@ namespace detail
) )
{ {
assert(x > genType(0)); // log2 is only defined on the range (0, inf] assert(x > genType(0)); // log2 is only defined on the range (0, inf]
return detail::compute_log2<detail::float_or_int_trait<genType>::ID>()(x); return _detail::_compute_log2<detail::float_or_int_trait<genType>::ID>()(x);
} }
VECTORIZE_VEC(log2) VECTORIZE_VEC(log2)

View File

@ -17,11 +17,13 @@ namespace detail
struct compute_linearRand struct compute_linearRand
{ {
template <typename T> template <typename T>
GLM_FUNC_QUALIFIER T operator() (T const & Min, T const & Max) const GLM_FUNC_QUALIFIER T operator() (T const & Min, T const & Max) const;
/*
{ {
GLM_STATIC_ASSERT(0, "'linearRand' invalid template parameter type. GLM_GTC_random only supports floating-point template types."); GLM_STATIC_ASSERT(0, "'linearRand' invalid template parameter type. GLM_GTC_random only supports floating-point template types.");
return Min; return Min;
} }
*/
}; };
template <> template <>
@ -41,6 +43,12 @@ namespace detail
{ {
return double(std::rand()) / double(RAND_MAX) * (Max - Min) + Min; return double(std::rand()) / double(RAND_MAX) * (Max - Min) + Min;
} }
template <>
GLM_FUNC_QUALIFIER long double compute_linearRand::operator()<long double> (long double const & Min, long double const & Max) const
{
return (long double)(std::rand()) / (long double)(RAND_MAX) * (Max - Min) + Min;
}
}//namespace detail }//namespace detail
template <typename genType> template <typename genType>

View File

@ -38,7 +38,7 @@ namespace glm
} }
// Henry Gordon Dietz: http://aggregate.org/MAGIC/ // Henry Gordon Dietz: http://aggregate.org/MAGIC/
namespace detail namespace _detail
{ {
GLM_FUNC_QUALIFIER unsigned int ones32(unsigned int x) GLM_FUNC_QUALIFIER unsigned int ones32(unsigned int x)
{ {
@ -55,7 +55,7 @@ namespace detail
} }
template <> template <>
struct compute_log2<float_or_int_value::GLM_INT> struct _compute_log2<detail::float_or_int_value::GLM_INT>
{ {
template <typename T> template <typename T>
T operator() (T const & Value) const T operator() (T const & Value) const
@ -67,7 +67,8 @@ namespace detail
#endif #endif
} }
}; };
}//namespace detail
}//namespace _detail
// Henry Gordon Dietz: http://aggregate.org/MAGIC/ // Henry Gordon Dietz: http://aggregate.org/MAGIC/
unsigned int floor_log2(unsigned int x) unsigned int floor_log2(unsigned int x)
@ -78,7 +79,7 @@ namespace detail
x |= (x >> 8); x |= (x >> 8);
x |= (x >> 16); x |= (x >> 16);
return(detail::ones32(x) - 1); return(_detail::ones32(x) - 1);
} }
// mod // mod

View File

@ -7,12 +7,13 @@
// File : test/core/func_common.cpp // File : test/core/func_common.cpp
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
#include <glm/glm.hpp>
#include <glm/gtx/epsilon.hpp>
#include <cstdio>
#include <boost/array.hpp> #include <boost/array.hpp>
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread/thread.hpp> #include <boost/thread/thread.hpp>
#include <glm/glm.hpp>
#include <glm/ext.hpp>
#include <glm/gtx/epsilon.hpp>
#include <cstdio>
int test_modf() int test_modf()
{ {