mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1338374 - Make tl::Min/Max variadic. r=froydnj
--HG-- extra : rebase_source : 140441135e9ee1fcde0541e39a19e1a5c47203c8
This commit is contained in:
parent
318b206490
commit
1811cee01b
@ -27,15 +27,34 @@ namespace mozilla {
|
||||
namespace tl {
|
||||
|
||||
/** Compute min/max. */
|
||||
template<size_t I, size_t J>
|
||||
template<size_t Size, size_t... Rest>
|
||||
struct Min
|
||||
{
|
||||
static const size_t value = I < J ? I : J;
|
||||
static constexpr size_t value =
|
||||
Size < Min<Rest...>::value
|
||||
? Size
|
||||
: Min<Rest...>::value;
|
||||
};
|
||||
template<size_t I, size_t J>
|
||||
|
||||
template<size_t Size>
|
||||
struct Min<Size>
|
||||
{
|
||||
static constexpr size_t value = Size;
|
||||
};
|
||||
|
||||
template<size_t Size, size_t... Rest>
|
||||
struct Max
|
||||
{
|
||||
static const size_t value = I > J ? I : J;
|
||||
static constexpr size_t value =
|
||||
Size > Max<Rest...>::value
|
||||
? Size
|
||||
: Max<Rest...>::value;
|
||||
};
|
||||
|
||||
template<size_t Size>
|
||||
struct Max<Size>
|
||||
{
|
||||
static constexpr size_t value = Size;
|
||||
};
|
||||
|
||||
/** Compute floor(log2(i)). */
|
||||
|
Loading…
Reference in New Issue
Block a user