last_of.hpp 859 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef BOOST_METAPARSE_V1_CPP11_LAST_OF_HPP
  2. #define BOOST_METAPARSE_V1_CPP11_LAST_OF_HPP
  3. // Copyright Abel Sinkovics ([email protected]) 2017.
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #include <boost/metaparse/v1/cpp11/impl/nth_of_c.hpp>
  8. #include <boost/metaparse/v1/fail.hpp>
  9. #include <boost/metaparse/v1/error/index_out_of_range.hpp>
  10. namespace boost
  11. {
  12. namespace metaparse
  13. {
  14. namespace v1
  15. {
  16. template <class... Ps>
  17. struct last_of
  18. {
  19. typedef last_of type;
  20. template <class S, class Pos>
  21. struct apply : impl::nth_of_c<sizeof...(Ps) - 1, S, Pos, Ps...> {};
  22. };
  23. template <>
  24. struct last_of<> : fail<error::index_out_of_range<0, -1, 0>> {};
  25. }
  26. }
  27. }
  28. #endif