Differential D3094 Diff 14018 ps/trunk/libraries/source/spidermonkey/include-win32-debug/mozilla/ArrayUtils.h
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/libraries/source/spidermonkey/include-win32-debug/mozilla/ArrayUtils.h
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Compute the length of an array with constant length. (Use of this method | * Compute the length of an array with constant length. (Use of this method | ||||
* with a non-array pointer will not compile.) | * with a non-array pointer will not compile.) | ||||
* | * | ||||
* Beware of the implicit trailing '\0' when using this with string constants. | * Beware of the implicit trailing '\0' when using this with string constants. | ||||
*/ | */ | ||||
template<typename T, size_t N> | template<typename T, size_t N> | ||||
MOZ_CONSTEXPR size_t | constexpr size_t | ||||
ArrayLength(T (&aArr)[N]) | ArrayLength(T (&aArr)[N]) | ||||
{ | { | ||||
return N; | return N; | ||||
} | } | ||||
template<typename T, size_t N> | template<typename T, size_t N> | ||||
MOZ_CONSTEXPR size_t | constexpr size_t | ||||
ArrayLength(const Array<T, N>& aArr) | ArrayLength(const Array<T, N>& aArr) | ||||
{ | { | ||||
return N; | return N; | ||||
} | } | ||||
template<typename E, E N, typename T> | template<typename E, E N, typename T> | ||||
MOZ_CONSTEXPR size_t | constexpr size_t | ||||
ArrayLength(const EnumeratedArray<E, N, T>& aArr) | ArrayLength(const EnumeratedArray<E, N, T>& aArr) | ||||
{ | { | ||||
return size_t(N); | return size_t(N); | ||||
} | } | ||||
/* | /* | ||||
* Compute the address one past the last element of a constant-length array. | * Compute the address one past the last element of a constant-length array. | ||||
* | * | ||||
* Beware of the implicit trailing '\0' when using this with string constants. | * Beware of the implicit trailing '\0' when using this with string constants. | ||||
*/ | */ | ||||
template<typename T, size_t N> | template<typename T, size_t N> | ||||
MOZ_CONSTEXPR T* | constexpr T* | ||||
ArrayEnd(T (&aArr)[N]) | ArrayEnd(T (&aArr)[N]) | ||||
{ | { | ||||
return aArr + ArrayLength(aArr); | return aArr + ArrayLength(aArr); | ||||
} | } | ||||
template<typename T, size_t N> | template<typename T, size_t N> | ||||
MOZ_CONSTEXPR T* | constexpr T* | ||||
ArrayEnd(Array<T, N>& aArr) | ArrayEnd(Array<T, N>& aArr) | ||||
{ | { | ||||
return &aArr[0] + ArrayLength(aArr); | return &aArr[0] + ArrayLength(aArr); | ||||
} | } | ||||
template<typename T, size_t N> | template<typename T, size_t N> | ||||
MOZ_CONSTEXPR const T* | constexpr const T* | ||||
ArrayEnd(const Array<T, N>& aArr) | ArrayEnd(const Array<T, N>& aArr) | ||||
{ | { | ||||
return &aArr[0] + ArrayLength(aArr); | return &aArr[0] + ArrayLength(aArr); | ||||
} | } | ||||
namespace detail { | namespace detail { | ||||
template<typename AlignType, typename Pointee, | template<typename AlignType, typename Pointee, | ||||
▲ Show 20 Lines • Show All 91 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator