at.hpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*!
  2. @file
  3. Defines `boost::hana::detail::variadic::at`.
  4. @copyright Louis Dionne 2013-2017
  5. Distributed under the Boost Software License, Version 1.0.
  6. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  7. */
  8. #ifndef BOOST_HANA_DETAIL_VARIADIC_AT_HPP
  9. #define BOOST_HANA_DETAIL_VARIADIC_AT_HPP
  10. #include <boost/hana/config.hpp>
  11. #include <cstddef>
  12. #include <utility>
  13. BOOST_HANA_NAMESPACE_BEGIN namespace detail { namespace variadic {
  14. template <std::size_t n, typename = std::make_index_sequence<n>>
  15. struct at_type;
  16. template <std::size_t n, std::size_t ...ignore>
  17. struct at_type<n, std::index_sequence<ignore...>> {
  18. private:
  19. template <typename Nth>
  20. static constexpr auto go(decltype(ignore, (void*)0)..., Nth nth, ...)
  21. { return nth; }
  22. public:
  23. template <typename ...Xs>
  24. constexpr auto operator()(Xs ...xs) const
  25. { return *go(&xs...); }
  26. };
  27. template <std::size_t n>
  28. constexpr at_type<n> at{};
  29. }} BOOST_HANA_NAMESPACE_END
  30. #endif // !BOOST_HANA_DETAIL_VARIADIC_AT_HPP