// // Copyright (c) 2016-2019 Damian Jarek (damian dot jarek93 at gmail dot com) // Copyright (c) 2022 Vinnie Falco (vinnie dot falco at gmail dot com) // // 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) // // Official repository: https://github.com/boostorg/beast // #ifndef BOOST_URL_GRAMMAR_DETAIL_TUPLE_HPP #define BOOST_URL_GRAMMAR_DETAIL_TUPLE_HPP #include #include #include #include #include #include #include #include #include #include #ifndef BOOST_URL_TUPLE_EBO // VFALCO No idea what causes it or how to fix it // https://devblogs.microsoft.com/cppblog/optimizing-the-layout-of-empty-base-classes-in-vs2015-update-2-3/ #ifdef BOOST_MSVC #define BOOST_URL_TUPLE_EBO 0 #else #define BOOST_URL_TUPLE_EBO 1 #endif #endif namespace boost { namespace urls { namespace grammar { namespace detail { #if BOOST_URL_TUPLE_EBO template struct tuple_element_impl : urls::detail::empty_value { constexpr tuple_element_impl(T const& t) : urls::detail::empty_value( urls::detail::empty_init, t) { } constexpr tuple_element_impl(T&& t) : urls::detail::empty_value( urls::detail::empty_init, std::move(t)) { } }; #else template struct tuple_element_impl { T t_; constexpr tuple_element_impl(T const& t) : t_(t) { } constexpr tuple_element_impl(T&& t) : t_(std::move(t)) { } constexpr T& get() noexcept { return t_; } constexpr T const& get() const noexcept { return t_; } }; #endif template struct tuple_element_impl { T& t; constexpr tuple_element_impl(T& t_) : t(t_) { } T& get() const noexcept { return t; } }; template struct tuple_impl; template struct tuple_impl< mp11::index_sequence, Ts...> : tuple_element_impl... { template constexpr explicit tuple_impl(Us&&... us) : tuple_element_impl( std::forward(us))... { } }; template struct tuple : tuple_impl< mp11::index_sequence_for, Ts...> { template...>::value && ! mp11::mp_all...>::value>::value, int>::type = 0 > constexpr explicit tuple(Us&&... us) noexcept : tuple_impl, Ts...>{std::forward(us)...} { } template...>::value, int>::type = 0 > constexpr tuple(Us&&... us) noexcept : tuple_impl, Ts...>{std::forward(us)...} { } }; //------------------------------------------------ template constexpr T& get(tuple_element_impl& te) { return te.get(); } template constexpr T const& get(tuple_element_impl const& te) { return te.get(); } template constexpr T&& get(tuple_element_impl&& te) { return std::move(te.get()); } template constexpr T& get(tuple_element_impl&& te) { return te.get(); } template using tuple_element = typename boost::copy_cv< mp11::mp_at_c::type, I>, T>::type; } // detail } // grammar } // urls } // boost #endif