2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2019-01-07 08:47:17 +00:00
|
|
|
Copyright (c) 2011-2019 Bolero MURAKAMI
|
2013-08-08 09:54:33 +00:00
|
|
|
https://github.com/bolero-MURAKAMI/Sprout
|
|
|
|
|
|
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
=============================================================================*/
|
2012-10-04 16:53:39 +00:00
|
|
|
#ifndef SPROUT_VARIANT_TUPLE_HPP
|
|
|
|
#define SPROUT_VARIANT_TUPLE_HPP
|
|
|
|
|
|
|
|
#include <tuple>
|
|
|
|
#include <sprout/config.hpp>
|
2014-04-30 07:30:26 +00:00
|
|
|
#include <sprout/workaround/std/cstddef.hpp>
|
2012-10-04 16:53:39 +00:00
|
|
|
#include <sprout/variant/variant.hpp>
|
|
|
|
#include <sprout/utility/move.hpp>
|
2014-05-28 15:25:37 +00:00
|
|
|
#include <sprout/tuple/tuple/tuple_element.hpp>
|
2012-10-04 16:53:39 +00:00
|
|
|
#include <sprout/tuple/tuple/get.hpp>
|
|
|
|
|
2012-10-05 15:58:56 +00:00
|
|
|
namespace sprout {
|
2012-10-04 16:53:39 +00:00
|
|
|
//
|
|
|
|
// tuple_get
|
|
|
|
//
|
|
|
|
template<std::size_t I, typename... Types>
|
|
|
|
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<
|
|
|
|
I,
|
|
|
|
sprout::variant<Types...>
|
|
|
|
>::type const&
|
|
|
|
tuple_get(sprout::variant<Types...> const& t) {
|
|
|
|
return t.template get_at<I>();
|
|
|
|
}
|
|
|
|
template<std::size_t I, typename... Types>
|
|
|
|
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<
|
|
|
|
I,
|
|
|
|
sprout::variant<Types...>
|
|
|
|
>::type&
|
|
|
|
tuple_get(sprout::variant<Types...>& t) {
|
|
|
|
return t.template get_at<I>();
|
|
|
|
}
|
|
|
|
template<std::size_t I, typename... Types>
|
|
|
|
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<
|
|
|
|
I,
|
|
|
|
sprout::variant<Types...>
|
|
|
|
>::type&&
|
|
|
|
tuple_get(sprout::variant<Types...>&& t) {
|
|
|
|
return sprout::move(sprout::tuples::get<I>(t));
|
|
|
|
}
|
2012-10-05 15:58:56 +00:00
|
|
|
} // namespace sprout
|
2012-10-04 16:53:39 +00:00
|
|
|
|
|
|
|
namespace std {
|
2012-11-15 09:36:55 +00:00
|
|
|
#if defined(__clang__)
|
|
|
|
# pragma clang diagnostic push
|
|
|
|
# pragma clang diagnostic ignored "-Wmismatched-tags"
|
|
|
|
#endif
|
2012-10-04 16:53:39 +00:00
|
|
|
//
|
|
|
|
// tuple_size
|
|
|
|
//
|
|
|
|
template<typename... Types>
|
|
|
|
struct tuple_size<sprout::variant<Types...> >
|
|
|
|
: public std::tuple_size<typename sprout::variant<Types...>::tuple_type>
|
|
|
|
{};
|
|
|
|
|
|
|
|
//
|
|
|
|
// tuple_element
|
|
|
|
//
|
|
|
|
template<std::size_t I, typename... Types>
|
|
|
|
struct tuple_element<I, sprout::variant<Types...> >
|
2014-05-28 15:25:37 +00:00
|
|
|
: public sprout::tuples::tuple_element<I, typename sprout::variant<Types...>::tuple_type>
|
2012-10-04 16:53:39 +00:00
|
|
|
{};
|
2012-11-15 09:36:55 +00:00
|
|
|
#if defined(__clang__)
|
|
|
|
# pragma clang diagnostic pop
|
|
|
|
#endif
|
2012-10-04 16:53:39 +00:00
|
|
|
} // namespace std
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_VARIANT_TUPLE_HPP
|