tuple additions/fixes
This commit is contained in:
parent
13ef36ba01
commit
cd6e2a96aa
|
@ -11,6 +11,7 @@
|
||||||
#include "octa/algorithm.hh"
|
#include "octa/algorithm.hh"
|
||||||
#include "octa/range.hh"
|
#include "octa/range.hh"
|
||||||
#include "octa/string.hh"
|
#include "octa/string.hh"
|
||||||
|
#include "octa/internal/tuple.hh"
|
||||||
|
|
||||||
namespace octa {
|
namespace octa {
|
||||||
|
|
||||||
|
@ -75,6 +76,31 @@ struct Array {
|
||||||
T p_buf[(N > 0) ? N : 1];
|
T p_buf[(N > 0) ? N : 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T, Size N>
|
||||||
|
struct TupleSize<Array<T, N>>: IntegralConstant<Size, N> {};
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
template<Size I, typename T, Size N>
|
||||||
|
struct TupleElementBase<I, Array<T, N>> {
|
||||||
|
using Type = T;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
template<Size I, typename T, Size N>
|
||||||
|
TupleElement<I, Array<T, N>> &get(Array<T, N> &a) {
|
||||||
|
return a[I];
|
||||||
|
}
|
||||||
|
|
||||||
|
template<Size I, typename T, Size N>
|
||||||
|
const TupleElement<I, Array<T, N>> &get(const Array<T, N> &a) {
|
||||||
|
return a[I];
|
||||||
|
}
|
||||||
|
|
||||||
|
template<Size I, typename T, Size N>
|
||||||
|
TupleElement<I, Array<T, N>> &&get(Array<T, N> &&a) {
|
||||||
|
return a[I];
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace octa */
|
} /* namespace octa */
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -372,7 +372,7 @@ public:
|
||||||
>
|
>
|
||||||
>::value
|
>::value
|
||||||
>> Tuple(AllocatorArg, const Alloc &a, T &&...t):
|
>> Tuple(AllocatorArg, const Alloc &a, T &&...t):
|
||||||
p_base(detail::MakeTupleIndices<sizeof...(T)>(),
|
p_base(allocator_arg, a, detail::MakeTupleIndices<sizeof...(T)>(),
|
||||||
detail::MakeTupleTypes<Tuple, sizeof...(T)>(),
|
detail::MakeTupleTypes<Tuple, sizeof...(T)>(),
|
||||||
detail::MakeTupleIndices<sizeof...(A), sizeof...(T)>(),
|
detail::MakeTupleIndices<sizeof...(A), sizeof...(T)>(),
|
||||||
detail::MakeTupleTypes<Tuple, sizeof...(A), sizeof...(T)>(),
|
detail::MakeTupleTypes<Tuple, sizeof...(A), sizeof...(T)>(),
|
||||||
|
|
|
@ -170,9 +170,6 @@ Pair<typename detail::MakePairRet<T>::Type,
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
struct TupleSize<Pair<T, U>>: IntegralConstant<Size, 2> {};
|
struct TupleSize<Pair<T, U>>: IntegralConstant<Size, 2> {};
|
||||||
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct TupleSize<const Pair<T, U>>: IntegralConstant<Size, 2> {};
|
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
struct TupleElementBase<0, Pair<T, U>> {
|
struct TupleElementBase<0, Pair<T, U>> {
|
||||||
|
@ -184,16 +181,6 @@ namespace detail {
|
||||||
using Type = U;
|
using Type = U;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct TupleElementBase<0, const Pair<T, U>> {
|
|
||||||
using Type = const T;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T, typename U>
|
|
||||||
struct TupleElementBase<1, const Pair<T, U>> {
|
|
||||||
using Type = const U;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<Size> struct GetPair;
|
template<Size> struct GetPair;
|
||||||
|
|
||||||
template<> struct GetPair<0> {
|
template<> struct GetPair<0> {
|
||||||
|
|
Loading…
Reference in a new issue