1 #ifndef BOOST_METAPARSE_V1_CPP11_IMPL_STRING_AT_HPP
2 #define BOOST_METAPARSE_V1_CPP11_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/limit_string_size.hpp>
19 template <int MaxLen, int Len, class T>
20 constexpr T string_at(const T (&s)[Len], int n)
22 // "MaxLen + 1" adds the \0 character of the string literal to the
24 static_assert(Len <= MaxLen + 1, "String literal is too long.");
25 return n >= Len - 1 ? T() : s[n];
32 #ifdef BOOST_METAPARSE_V1_STRING_AT
33 # error BOOST_METAPARSE_V1_STRING_AT already defined
35 #define BOOST_METAPARSE_V1_STRING_AT \
36 ::boost::metaparse::v1::impl::string_at<BOOST_METAPARSE_LIMIT_STRING_SIZE>