Created
November 4, 2019 15:48
-
-
Save loliGothicK/23bcb586c4debfc7142e56de9cec5e89 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef MITAMA_RANGE_VIEW_FLIP_HPP | |
#define MITAMA_RANGE_VIEW_FLIP_HPP | |
#include <range/v3/all.hpp> | |
#include <utility> | |
#include <type_traits> | |
#include <tuple> | |
namespace mitama::views { | |
inline constexpr auto flip = ranges::views::transform([](auto&& t){ | |
static_assert(std::tuple_size_v<std::decay_t<decltype(t)>> >= 2); | |
if constexpr (std::tuple_size_v<std::decay_t<decltype(t)>> == 2) { | |
return std::forward_as_tuple(std::get<1>(t), std::get<0>(t)); | |
} | |
else { | |
static_assert([]{ return false; }()); | |
} | |
}); | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment