Skip to content

Instantly share code, notes, and snippets.

@loliGothicK
Created November 4, 2019 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loliGothicK/23bcb586c4debfc7142e56de9cec5e89 to your computer and use it in GitHub Desktop.
Save loliGothicK/23bcb586c4debfc7142e56de9cec5e89 to your computer and use it in GitHub Desktop.
#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