1 #ifndef BOOST_METAPARSE_V1_IMPL_STRING_AT_HPP
2 #define BOOST_METAPARSE_V1_IMPL_STRING_AT_HPP
4 // Copyright Abel Sinkovics (abel@sinkovics.hu) 2016.
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 #include <boost/metaparse/config.hpp>
10 #include <boost/static_assert.hpp>
11 #include <boost/metaparse/v1/impl/no_char.hpp>
21 template <int MaxLen, int Len, class T>
22 BOOST_CONSTEXPR int string_at(const T (&s)[Len], int n)
24 // "MaxLen + 1" adds the \0 character of the string literal to the
26 BOOST_STATIC_ASSERT((Len <= MaxLen + 1));
27 return n >= Len - 1 ? BOOST_NO_CHAR : s[n];
34 #ifdef BOOST_METAPARSE_V1_STRING_AT
35 # error BOOST_METAPARSE_V1_STRING_AT already defined
37 #define BOOST_METAPARSE_V1_STRING_AT \
38 ::boost::metaparse::v1::impl::string_at<BOOST_METAPARSE_LIMIT_STRING_SIZE>