Ticket #137, added constexpr support

This commit is contained in:
Christophe Riccio 2012-01-25 18:36:04 +00:00
parent 080dc2dd82
commit fb3a41995a
31 changed files with 119 additions and 104 deletions

View File

@ -444,6 +444,7 @@ namespace detail
# define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct
# define GLM_RESTRICT __declspec(restrict)
# define GLM_RESTRICT_VAR __restrict
# define GLM_CONSTEXPR
#elif((GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC)) && (GLM_COMPILER >= GLM_COMPILER_GCC31))
# define GLM_DEPRECATED __attribute__((__deprecated__))
# define GLM_ALIGN(x) __attribute__((aligned(x)))
@ -457,12 +458,18 @@ namespace detail
# endif
# define GLM_RESTRICT __restrict__
# define GLM_RESTRICT_VAR __restrict__
# if((GLM_COMPILER >= GLM_COMPILER_GCC47) && ((GLM_LANG & GLM_LANG_CXX0X) == GLM_LANG_CXX0X))
# define GLM_CONSTEXPR constexpr
# else
# define GLM_CONSTEXPR
# endif
#else
# define GLM_DEPRECATED
# define GLM_ALIGN
# define GLM_ALIGNED_STRUCT(x)
# define GLM_RESTRICT
# define GLM_RESTRICT_VAR
# define GLM_CONSTEXPR
#endif//GLM_COMPILER
#endif//glm_core_detail

View File

@ -53,27 +53,27 @@ namespace detail
template <typename T>
struct tmat2x2
{
// Implementation detail
// Implementation detail
enum ctor{null};
typedef T value_type;
typedef std::size_t size_type;
typedef tvec2<T> col_type;
typedef tvec2<T> row_type;
static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size();
typedef tmat2x2<T> type;
typedef tmat2x2<T> transpose_type;
GLM_FUNC_DECL size_type length() const;
static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size();
GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
public:
// Implementation detail
// Implementation detail
GLM_FUNC_DECL tmat2x2<T> _inverse() const;
private:
//////////////////////////////////////
// Implementation detail
// Implementation detail
col_type value[2];
public:

View File

@ -30,7 +30,7 @@ namespace glm{
namespace detail
{
template <typename T>
GLM_FUNC_QUALIFIER typename tmat2x2<T>::size_type tmat2x2<T>::length() const
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat2x2<T>::size_type tmat2x2<T>::length() const
{
return 2;
}

View File

@ -58,12 +58,13 @@ namespace detail
typedef std::size_t size_type;
typedef tvec3<T> col_type;
typedef tvec2<T> row_type;
GLM_FUNC_DECL size_type length() const;
typedef tmat2x3<T> type;
typedef tmat3x2<T> transpose_type;
static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size();
typedef tmat2x3<T> type;
typedef tmat3x2<T> transpose_type;
GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
private:
// Data

View File

@ -30,7 +30,7 @@ namespace glm{
namespace detail
{
template <typename T>
GLM_FUNC_QUALIFIER typename tmat2x3<T>::size_type tmat2x3<T>::length() const
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat2x3<T>::size_type tmat2x3<T>::length() const
{
return 2;
}

View File

@ -58,12 +58,13 @@ namespace detail
typedef std::size_t size_type;
typedef tvec4<T> col_type;
typedef tvec2<T> row_type;
GLM_FUNC_DECL size_type length() const;
typedef tmat2x4<T> type;
typedef tmat4x2<T> transpose_type;
static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size();
typedef tmat2x4<T> type;
typedef tmat4x2<T> transpose_type;
GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
private:
// Data

View File

@ -30,7 +30,7 @@ namespace glm{
namespace detail
{
template <typename T>
GLM_FUNC_QUALIFIER typename tmat2x4<T>::size_type tmat2x4<T>::length() const
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat2x4<T>::size_type tmat2x4<T>::length() const
{
return 2;
}

View File

@ -58,12 +58,13 @@ namespace detail
typedef std::size_t size_type;
typedef tvec2<T> col_type;
typedef tvec3<T> row_type;
GLM_FUNC_DECL size_type length() const;
typedef tmat3x2<T> type;
typedef tmat2x3<T> transpose_type;
static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size();
typedef tmat3x2<T> type;
typedef tmat2x3<T> transpose_type;
GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
private:
// Data

View File

@ -30,7 +30,7 @@ namespace glm{
namespace detail
{
template <typename T>
GLM_FUNC_QUALIFIER typename tmat3x2<T>::size_type tmat3x2<T>::length() const
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat3x2<T>::size_type tmat3x2<T>::length() const
{
return 3;
}

View File

@ -58,12 +58,13 @@ namespace detail
typedef std::size_t size_type;
typedef tvec3<T> col_type;
typedef tvec3<T> row_type;
GLM_FUNC_DECL size_type length() const;
typedef tmat3x3<T> type;
typedef tmat3x3<T> transpose_type;
static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size();
typedef tmat3x3<T> type;
typedef tmat3x3<T> transpose_type;
GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
public:
/// Implementation detail

View File

@ -30,7 +30,7 @@ namespace glm{
namespace detail
{
template <typename T>
GLM_FUNC_QUALIFIER typename tmat3x3<T>::size_type tmat3x3<T>::length() const
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat3x3<T>::size_type tmat3x3<T>::length() const
{
return 3;
}

View File

@ -58,12 +58,13 @@ namespace detail
typedef std::size_t size_type;
typedef tvec4<T> col_type;
typedef tvec3<T> row_type;
GLM_FUNC_DECL size_type length() const;
typedef tmat3x4<T> type;
typedef tmat4x3<T> transpose_type;
static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size();
typedef tmat3x4<T> type;
typedef tmat4x3<T> transpose_type;
GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
private:
// Data

View File

@ -30,7 +30,7 @@ namespace glm{
namespace detail
{
template <typename T>
GLM_FUNC_QUALIFIER typename tmat3x4<T>::size_type tmat3x4<T>::length() const
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat3x4<T>::size_type tmat3x4<T>::length() const
{
return 3;
}

View File

@ -58,12 +58,13 @@ namespace detail
typedef std::size_t size_type;
typedef tvec2<T> col_type;
typedef tvec4<T> row_type;
GLM_FUNC_DECL size_type length() const;
typedef tmat4x2<T> type;
typedef tmat2x4<T> transpose_type;
static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size();
typedef tmat4x2<T> type;
typedef tmat2x4<T> transpose_type;
GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
private:
// Data

View File

@ -30,7 +30,7 @@ namespace glm{
namespace detail
{
template <typename T>
GLM_FUNC_QUALIFIER typename tmat4x2<T>::size_type tmat4x2<T>::length() const
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat4x2<T>::size_type tmat4x2<T>::length() const
{
return 4;
}

View File

@ -58,12 +58,13 @@ namespace detail
typedef std::size_t size_type;
typedef tvec3<T> col_type;
typedef tvec4<T> row_type;
GLM_FUNC_DECL size_type length() const;
typedef tmat4x3<T> type;
typedef tmat3x4<T> transpose_type;
static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size();
typedef tmat4x3<T> type;
typedef tmat3x4<T> transpose_type;
GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
private:
// Data

View File

@ -30,7 +30,7 @@ namespace glm{
namespace detail
{
template <typename T>
GLM_FUNC_QUALIFIER typename tmat4x3<T>::size_type tmat4x3<T>::length() const
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat4x3<T>::size_type tmat4x3<T>::length() const
{
return 4;
}

View File

@ -58,12 +58,13 @@ namespace detail
typedef std::size_t size_type;
typedef tvec4<T> col_type;
typedef tvec4<T> row_type;
GLM_FUNC_DECL size_type length() const;
typedef tmat4x4<T> type;
typedef tmat4x4<T> transpose_type;
static GLM_FUNC_DECL size_type col_size();
static GLM_FUNC_DECL size_type row_size();
typedef tmat4x4<T> type;
typedef tmat4x4<T> transpose_type;
GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
public:
/// Implementation detail

View File

@ -30,7 +30,7 @@ namespace glm{
namespace detail
{
template <typename T>
GLM_FUNC_QUALIFIER typename tmat4x4<T>::size_type tmat4x4<T>::length() const
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tmat4x4<T>::size_type tmat4x4<T>::length() const
{
return 4;
}

View File

@ -54,11 +54,11 @@ namespace detail
typedef T value_type;
typedef std::size_t size_type;
GLM_FUNC_DECL size_type length() const;
typedef tvec1<T> type;
typedef tvec1<bool> bool_type;
GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
//////////////////////////////////////
// Data

View File

@ -30,7 +30,7 @@ namespace glm{
namespace detail
{
template <typename T>
GLM_FUNC_QUALIFIER typename tvec1<T>::size_type tvec1<T>::length() const
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tvec1<T>::size_type tvec1<T>::length() const
{
return 1;
}

View File

@ -53,11 +53,11 @@ namespace detail
typedef T value_type;
typedef std::size_t size_type;
GLM_FUNC_DECL size_type length() const;
typedef tvec2<T> type;
typedef tvec2<bool> bool_type;
GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
//////////////////////////////////////
// Data

View File

@ -30,7 +30,7 @@ namespace glm{
namespace detail
{
template <typename T>
GLM_FUNC_QUALIFIER typename tvec2<T>::size_type tvec2<T>::length() const
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tvec2<T>::size_type tvec2<T>::length() const
{
return 2;
}

View File

@ -53,11 +53,11 @@ namespace detail
typedef T value_type;
typedef std::size_t size_type;
GLM_FUNC_DECL size_type length() const;
typedef tvec3<T> type;
typedef tvec3<bool> bool_type;
GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
//////////////////////////////////////
// Data

View File

@ -30,7 +30,7 @@ namespace glm{
namespace detail
{
template <typename T>
GLM_FUNC_QUALIFIER typename tvec3<T>::size_type tvec3<T>::length() const
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tvec3<T>::size_type tvec3<T>::length() const
{
return 3;
}

View File

@ -53,11 +53,11 @@ namespace detail
typedef T value_type;
typedef std::size_t size_type;
GLM_FUNC_DECL size_type length() const;
typedef tvec4<T> type;
typedef tvec4<bool> bool_type;
GLM_FUNC_DECL GLM_CONSTEXPR size_type length() const;
//////////////////////////////////////
// Data

View File

@ -30,7 +30,7 @@ namespace glm{
namespace detail
{
template <typename T>
GLM_FUNC_QUALIFIER typename tvec4<T>::size_type tvec4<T>::length() const
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tvec4<T>::size_type tvec4<T>::length() const
{
return 4;
}

View File

@ -32,7 +32,7 @@
///
/// @brief Define secant, cosecant and cotangent functions.
///
/// <glm/gtc/reciprocal.hpp> need to be included to use these functionalities.
/// <glm/gtc/reciprocal.hpp> need to be included to use these features.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_reciprocal

View File

@ -33,7 +33,7 @@
/// @brief Allow the measurement of the accuracy of a function against a reference
/// implementation. This extension works on floating-point data and provide results
/// in ULP.
/// <glm/gtc/ulp.hpp> need to be included to use these functionalities.
/// <glm/gtc/ulp.hpp> need to be included to use these features.
///////////////////////////////////////////////////////////////////////////////////
#ifndef GLM_GTC_ulp

View File

@ -56,127 +56,127 @@ namespace glm
/// @todo Implement epsilon for half-precision floating point type.
/// @see gtx_constants
template <typename T>
T epsilon();
GLM_CONSTEXPR T epsilon();
/// Return 0.
/// @see gtx_constants
template <typename T>
T zero();
GLM_CONSTEXPR T zero();
/// Return 1.
/// @see gtx_constants
template <typename T>
T one();
GLM_CONSTEXPR T one();
/// Return the pi constant.
/// @see gtx_constants
template <typename T>
T pi();
GLM_CONSTEXPR T pi();
/// Return square root of pi.
/// @see gtx_constants
template <typename T>
T root_pi();
GLM_CONSTEXPR T root_pi();
/// Return pi / 2.
/// @see gtx_constants
template <typename T>
T half_pi();
GLM_CONSTEXPR T half_pi();
/// Return pi / 4.
/// @see gtx_constants
template <typename T>
T quarter_pi();
GLM_CONSTEXPR T quarter_pi();
/// Return 1 / pi.
/// @see gtx_constants
template <typename T>
T one_over_pi();
GLM_CONSTEXPR T one_over_pi();
/// Return 2 / pi.
/// @see gtx_constants
template <typename T>
T two_over_pi();
GLM_CONSTEXPR T two_over_pi();
/// Return 2 / sqrt(pi).
/// @see gtx_constants
template <typename T>
T two_over_root_pi();
GLM_CONSTEXPR T two_over_root_pi();
/// Return 1 / sqrt(2).
/// @see gtx_constants
template <typename T>
T one_over_root_two();
GLM_CONSTEXPR T one_over_root_two();
/// Return sqrt(pi / 2).
/// @see gtx_constants
template <typename T>
T root_half_pi();
GLM_CONSTEXPR T root_half_pi();
/// Return sqrt(2 * pi).
/// @see gtx_constants
template <typename T>
T root_two_pi();
GLM_CONSTEXPR T root_two_pi();
/// Return sqrt(ln(4)).
/// @see gtx_constants
template <typename T>
T root_ln_four();
GLM_CONSTEXPR T root_ln_four();
/// Return e constant.
/// @see gtx_constants
template <typename T>
T e();
GLM_CONSTEXPR T e();
/// Return Euler's constant.
/// @see gtx_constants
template <typename T>
T euler();
GLM_CONSTEXPR T euler();
/// Return sqrt(2).
/// @see gtx_constants
template <typename T>
T root_two();
GLM_CONSTEXPR T root_two();
/// Return sqrt(3).
/// @see gtx_constants
template <typename T>
T root_three();
GLM_CONSTEXPR T root_three();
/// Return sqrt(5).
/// @see gtx_constants
template <typename T>
T root_five();
GLM_CONSTEXPR T root_five();
/// Return ln(2).
/// @see gtx_constants
template <typename T>
T ln_two();
GLM_CONSTEXPR T ln_two();
/// Return ln(10).
/// @see gtx_constants
template <typename T>
T ln_ten();
GLM_CONSTEXPR T ln_ten();
/// Return ln(ln(2)).
/// @see gtx_constants
template <typename T>
T ln_ln_two();
GLM_CONSTEXPR T ln_ln_two();
/// Return 1 / 3.
/// @see gtx_constants
template <typename T>
T third();
GLM_CONSTEXPR T third();
/// Return 2 / 3.
/// @see gtx_constants
template <typename T>
T two_thirds();
GLM_CONSTEXPR T two_thirds();
/// Return the golden ratio constant.
/// @see gtx_constants
template <typename T>
T golden_ratio();
GLM_CONSTEXPR T golden_ratio();
/// @}
} //namespace glm

View File

@ -29,151 +29,151 @@
namespace glm
{
template <typename T>
GLM_FUNC_QUALIFIER T epsilon()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T epsilon()
{
return std::numeric_limits<T>::epsilon();
}
template <typename T>
GLM_FUNC_QUALIFIER T zero()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T zero()
{
return T(0);
}
template <typename T>
GLM_FUNC_QUALIFIER T one()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T one()
{
return T(1);
}
template <typename T>
GLM_FUNC_QUALIFIER T pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T pi()
{
return T(3.14159265358979323846264338327950288);
}
template <typename T>
GLM_FUNC_QUALIFIER T root_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T root_pi()
{
return T(1.772453850905516027);
}
template <typename T>
GLM_FUNC_QUALIFIER T half_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T half_pi()
{
return T(1.57079632679489661923132169163975144);
}
template <typename T>
GLM_FUNC_QUALIFIER T quarter_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T quarter_pi()
{
return T(0.785398163397448309615660845819875721);
}
template <typename T>
GLM_FUNC_QUALIFIER T one_over_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T one_over_pi()
{
return T(0.318309886183790671537767526745028724);
}
template <typename T>
GLM_FUNC_QUALIFIER T two_over_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T two_over_pi()
{
return T(0.636619772367581343075535053490057448);
}
template <typename T>
GLM_FUNC_QUALIFIER T two_over_root_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T two_over_root_pi()
{
return T(1.12837916709551257389615890312154517);
}
template <typename T>
GLM_FUNC_QUALIFIER T one_over_root_two()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T one_over_root_two()
{
return T(0.707106781186547524400844362104849039);
}
template <typename T>
GLM_FUNC_QUALIFIER T root_half_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T root_half_pi()
{
return T(1.253314137315500251);
}
template <typename T>
GLM_FUNC_QUALIFIER T root_two_pi()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T root_two_pi()
{
return T(2.506628274631000502);
}
template <typename T>
GLM_FUNC_QUALIFIER T root_ln_four()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T root_ln_four()
{
return T(1.17741002251547469);
}
template <typename T>
GLM_FUNC_QUALIFIER T e()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T e()
{
return T(2.71828182845904523536);
}
template <typename T>
GLM_FUNC_QUALIFIER T euler()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T euler()
{
return T(0.577215664901532860606);
}
template <typename T>
GLM_FUNC_QUALIFIER T root_two()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T root_two()
{
return T(1.41421356237309504880168872420969808);
}
template <typename T>
GLM_FUNC_QUALIFIER T root_three()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T root_three()
{
return T(1.73205080756887729352744634150587236);
}
template <typename T>
GLM_FUNC_QUALIFIER T root_five()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T root_five()
{
return T(2.23606797749978969640917366873127623);
}
template <typename T>
GLM_FUNC_QUALIFIER T ln_two()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T ln_two()
{
return T(0.693147180559945309417232121458176568);
}
template <typename T>
GLM_FUNC_QUALIFIER T ln_ten()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T ln_ten()
{
return T(2.30258509299404568401799145468436421);
}
template <typename T>
GLM_FUNC_QUALIFIER T ln_ln_two()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T ln_ln_two()
{
return T(-0.3665129205816643);
}
template <typename T>
GLM_FUNC_QUALIFIER T third()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T third()
{
return T(0.3333333333333333333333333333333333333333);
}
template <typename T>
GLM_FUNC_QUALIFIER T two_thirds()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T two_thirds()
{
return T(0.666666666666666666666666666666666666667);
}
template <typename T>
GLM_FUNC_QUALIFIER T golden_ratio()
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T golden_ratio()
{
return T(1.61803398874989484820458683436563811);
}