size_type and length_type for all types

This commit is contained in:
Christophe Riccio
2014-11-29 00:53:47 +01:00
parent 3ad3dbcd93
commit be0c5da488
30 changed files with 948 additions and 641 deletions

View File

@@ -62,25 +62,30 @@ namespace glm
template <typename T, precision P>
struct tquat
{
typedef tquat<T, P> type;
typedef T value_type;
typedef tvec4<bool, P> bool_type;
public:
T x, y, z, w;
#if GLM_FORCE_SIZE_FUNC
/// Return the count of components of a quaternion
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
#else
/// Return the count of components of a quaternion
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
#endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Accesses
// Component accesses
GLM_FUNC_DECL T & operator[](length_t i);
GLM_FUNC_DECL T const & operator[](length_t i) const;
# ifdef GLM_FORCE_SIZE_FUNC
typedef size_t size_type;
/// Return the count of components of a quaternion
GLM_FUNC_DECL GLM_CONSTEXPR size_type size() const;
GLM_FUNC_DECL T & operator[](size_type i);
GLM_FUNC_DECL T const & operator[](size_type i) const;
# else
typedef length_t length_type;
/// Return the count of components of a quaternion
GLM_FUNC_DECL GLM_CONSTEXPR length_type length() const;
GLM_FUNC_DECL T & operator[](length_type i);
GLM_FUNC_DECL T const & operator[](length_type i) const;
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Implicit basic constructors

View File

@@ -49,43 +49,57 @@ namespace detail
};
}//namespace detail
#if GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tquat<T, P>::size() const
{
return 4;
}
#else
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tquat<T, P>::length() const
{
return 4;
}
#endif
//////////////////////////////////////
// Accesses
// Component accesses
template <typename T, precision P>
GLM_FUNC_QUALIFIER T & tquat<T, P>::operator[] (length_t i)
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
# ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tquat<T, P>::size_type tquat<T, P>::size() const
{
return 4;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T const & tquat<T, P>::operator[] (length_t i) const
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T & tquat<T, P>::operator[](typename tquat<T, P>::size_type i)
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T const & tquat<T, P>::operator[](typename tquat<T, P>::size_type i) const
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
# else
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename tquat<T, P>::length_type tquat<T, P>::length() const
{
return 4;
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T & tquat<T, P>::operator[](typename tquat<T, P>::length_type i)
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
template <typename T, precision P>
GLM_FUNC_QUALIFIER T const & tquat<T, P>::operator[](typename tquat<T, P>::length_type i) const
{
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}
# endif//GLM_FORCE_SIZE_FUNC
//////////////////////////////////////
// Implicit basic constructors
template <typename T, precision P>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat()
# ifndef GLM_FORCE_NO_CTOR_INIT
# ifndef GLM_FORCE_NO_CTOR_INIT
: x(0), y(0), z(0), w(1)
# endif
{}