]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/metaparse/v1/cpp11/impl/string_at.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / metaparse / v1 / cpp11 / impl / string_at.hpp
1 #ifndef BOOST_METAPARSE_V1_CPP11_IMPL_STRING_AT_HPP
2 #define BOOST_METAPARSE_V1_CPP11_IMPL_STRING_AT_HPP
3
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)
8
9 #include <boost/metaparse/limit_string_size.hpp>
10
11 namespace boost
12 {
13 namespace metaparse
14 {
15 namespace v1
16 {
17 namespace impl
18 {
19 template <int MaxLen, int Len, class T>
20 constexpr T string_at(const T (&s)[Len], int n)
21 {
22 // "MaxLen + 1" adds the \0 character of the string literal to the
23 // limit
24 static_assert(Len <= MaxLen + 1, "String literal is too long.");
25 return n >= Len - 1 ? T() : s[n];
26 }
27 }
28 }
29 }
30 }
31
32 #ifdef BOOST_METAPARSE_V1_STRING_AT
33 # error BOOST_METAPARSE_V1_STRING_AT already defined
34 #endif
35 #define BOOST_METAPARSE_V1_STRING_AT \
36 ::boost::metaparse::v1::impl::string_at<BOOST_METAPARSE_LIMIT_STRING_SIZE>
37
38 #endif
39