.. _program_listing_file_include_ripple_container_tuple.hpp: Program Listing for File tuple.hpp ================================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/ripple/container/tuple.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #ifndef RIPPLE_CONTAINER_TUPLE_HPP #define RIPPLE_CONTAINER_TUPLE_HPP #include "tuple_traits.hpp" #include "detail/basic_tuple_.hpp" namespace ripple { /*==--- [tuple implementation] ---------------------------------------------==*/ template <> class Tuple<> { using Storage = detail::BasicTuple<>; public: ripple_all constexpr Tuple() noexcept {} ripple_all constexpr auto size() const noexcept -> size_t { return 0; } }; template class Tuple { using Storage = detail::BasicTuple; static constexpr size_t elements = size_t{sizeof...(Ts)}; /*=--- [construction] ----------------------------------------------------==*/ template ripple_all constexpr explicit Tuple( T&& other, std::index_sequence extractor) noexcept : storage_{detail::get_impl(ripple_forward(other.data()))...} {} Storage storage_; public: ripple_all constexpr Tuple() noexcept : storage_{std::decay_t()...} {} ripple_all constexpr Tuple(const Ts&... es) noexcept : storage_{es...} {} template = 0> ripple_all constexpr Tuple(Types&&... es) noexcept : storage_{ripple_forward(es)...} {} /*==--- [move constructor] -----------------------------------------------==*/ template = 0> ripple_all constexpr explicit Tuple(T&& other) noexcept : Tuple{ripple_forward(other), std::make_index_sequence{}} {} /*==--- [interface] ------------------------------------------------------==*/ ripple_all constexpr auto size() const noexcept -> size_t { return elements; } ripple_all auto data() noexcept -> Storage& { return storage_; } ripple_all auto data() const noexcept -> const Storage& { return storage_; } }; /*==--- [get implemenation] ------------------------------------------------==*/ template ripple_all constexpr inline auto get(const Tuple& tuple) noexcept -> const std::decay_t>& { return detail::get_impl(tuple.data()); } template ripple_all constexpr inline auto get(Tuple& tuple) noexcept -> std::remove_reference_t>& { return detail::get_impl(tuple.data()); } template ripple_all constexpr inline auto get(Tuple&& tuple) noexcept -> std::remove_reference_t>&& { using DataType = decltype(tuple.data()); return detail::get_impl( static_cast&&>(tuple.data())); } template ripple_all constexpr inline auto get(const Tuple&& tuple) noexcept -> const std::decay_t>&& { using DataType = decltype(tuple.data()); return detail::get_impl( static_cast&&>(tuple.data())); } /*==--- [make tuple] -------------------------------------------------------==*/ template ripple_all constexpr inline auto make_tuple(Ts&&... values) noexcept -> Tuple...> { return Tuple...>{ripple_forward(values)...}; } } // namespace ripple #endif // RIPPLE_CONTAINER_TUPLE_HPP