diff options
author | vng <viktor.govako@gmail.com> | 2018-04-16 10:54:17 +0300 |
---|---|---|
committer | mpimenov <mpimenov@users.noreply.github.com> | 2018-04-24 13:44:37 +0300 |
commit | 30a1cff263f20a5bdf687ec9a3c6bc383846bd3a (patch) | |
tree | 4187d7c83fe7ca6e35257aea016e098319c9d9bd /std | |
parent | 6f52955e573759a8249716c28c98901a4094317d (diff) |
Use tuple instead of vector and pointers.
Diffstat (limited to 'std')
-rw-r--r-- | std/tuple.hpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/std/tuple.hpp b/std/tuple.hpp index 9e05d40bc4..b24361c793 100644 --- a/std/tuple.hpp +++ b/std/tuple.hpp @@ -5,11 +5,42 @@ #endif #include <tuple> +#include <type_traits> using std::tuple; using std::make_tuple; using std::get; + +template <size_t I = 0, typename FnT, typename... Tp> +typename std::enable_if<I == sizeof...(Tp), void>::type +for_each_tuple(std::tuple<Tp...> &, FnT &&) +{ +} + +template <size_t I = 0, typename FnT, typename... Tp> +typename std::enable_if<I != sizeof...(Tp), void>::type +for_each_tuple(std::tuple<Tp...> & t, FnT && fn) +{ + fn(I, std::get<I>(t)); + for_each_tuple<I + 1, FnT, Tp...>(t, std::forward<FnT>(fn)); +} + +template <size_t I = 0, typename FnT, typename... Tp> +typename std::enable_if<I == sizeof...(Tp), void>::type +for_each_tuple_const(std::tuple<Tp...> const &, FnT &&) +{ +} + +template <size_t I = 0, typename FnT, typename... Tp> +typename std::enable_if<I != sizeof...(Tp), void>::type +for_each_tuple_const(std::tuple<Tp...> const & t, FnT && fn) +{ + fn(I, std::get<I>(t)); + for_each_tuple_const<I + 1, FnT, Tp...>(t, std::forward<FnT>(fn)); +} + + #ifdef DEBUG_NEW #define new DEBUG_NEW #endif |