Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:09:43

0001 //
0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
0003 // Copyright (c) 2019-2020 Krystian Stasiowski (sdkrystian at gmail dot com)
0004 //
0005 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0006 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 //
0008 // Official repository: https://github.com/boostorg/static_string
0009 //
0010 
0011 #ifndef BOOST_STATIC_STRING_CONFIG_HPP
0012 #define BOOST_STATIC_STRING_CONFIG_HPP
0013 
0014 // Are we dependent on Boost?
0015 // #define BOOST_STATIC_STRING_STANDALONE
0016 
0017 #include <cstdint>
0018 
0019 // detect 32/64 bit
0020 #if UINTPTR_MAX == UINT64_MAX
0021 #define BOOST_STATIC_STRING_ARCH 64
0022 #elif UINTPTR_MAX == UINT32_MAX
0023 #define BOOST_STATIC_STRING_ARCH 32
0024 #else
0025 #error Unknown or unsupported architecture, please open an issue
0026 #endif
0027 
0028 // Can we have deduction guides?
0029 #if __cpp_deduction_guides >= 201703L
0030 #define BOOST_STATIC_STRING_USE_DEDUCT
0031 #endif
0032 
0033 // Include <version> if we can
0034 #ifdef __has_include
0035 #if __has_include(<version>)
0036 #include <version>
0037 #endif
0038 #endif
0039 
0040 // Can we use __has_builtin?
0041 #ifdef __has_builtin
0042 #define BOOST_STATIC_STRING_HAS_BUILTIN(arg) __has_builtin(arg)
0043 #else
0044 #define BOOST_STATIC_STRING_HAS_BUILTIN(arg) 0
0045 #endif
0046 
0047 // Can we use is_constant_evaluated?
0048 #if __cpp_lib_is_constant_evaluated >= 201811L
0049 #define BOOST_STATIC_STRING_IS_CONST_EVAL std::is_constant_evaluated()
0050 #elif BOOST_STATIC_STRING_HAS_BUILTIN(__builtin_is_constant_evaluated)
0051 #define BOOST_STATIC_STRING_IS_CONST_EVAL __builtin_is_constant_evaluated()
0052 #endif
0053 
0054 // Check for an attribute
0055 #if defined(__has_cpp_attribute)
0056 #define BOOST_STATIC_STRING_CHECK_FOR_ATTR(x) __has_cpp_attribute(x)
0057 #elif defined(__has_attribute)
0058 #define BOOST_STATIC_STRING_CHECK_FOR_ATTR(x) __has_attribute(x)
0059 #else
0060 #define BOOST_STATIC_STRING_CHECK_FOR_ATTR(x) 0
0061 #endif
0062 
0063 // Decide which attributes we can use
0064 #define BOOST_STATIC_STRING_UNLIKELY
0065 #define BOOST_STATIC_STRING_NODISCARD
0066 #define BOOST_STATIC_STRING_NORETURN
0067 #define BOOST_STATIC_STRING_NO_NORETURN
0068 // unlikely
0069 #if BOOST_STATIC_STRING_CHECK_FOR_ATTR(unlikely)
0070 #undef BOOST_STATIC_STRING_UNLIKELY
0071 #define BOOST_STATIC_STRING_UNLIKELY [[unlikely]]
0072 #endif
0073 // nodiscard
0074 #if BOOST_STATIC_STRING_CHECK_FOR_ATTR(nodiscard)
0075 #undef BOOST_STATIC_STRING_NODISCARD
0076 #define BOOST_STATIC_STRING_NODISCARD [[nodiscard]]
0077 #elif defined(_MSC_VER) && _MSC_VER >= 1700
0078 #undef BOOST_STATIC_STRING_NODISCARD
0079 #define BOOST_STATIC_STRING_NODISCARD _Check_return_
0080 #elif defined(__GNUC__) || defined(__clang__)
0081 #undef BOOST_STATIC_STRING_NODISCARD
0082 #define BOOST_STATIC_STRING_NODISCARD __attribute__((warn_unused_result))
0083 #endif
0084 // noreturn
0085 #if BOOST_STATIC_STRING_CHECK_FOR_ATTR(noreturn)
0086 #undef BOOST_STATIC_STRING_NORETURN
0087 #undef BOOST_STATIC_STRING_NO_NORETURN
0088 #define BOOST_STATIC_STRING_NORETURN [[noreturn]]
0089 #elif defined(_MSC_VER)
0090 #undef BOOST_STATIC_STRING_NORETURN
0091 #undef BOOST_STATIC_STRING_NO_NORETURN
0092 #define BOOST_STATIC_STRING_NORETURN __declspec(noreturn)
0093 #elif defined(__GNUC__) || defined(__clang__)
0094 #undef BOOST_STATIC_STRING_NORETURN
0095 #undef BOOST_STATIC_STRING_NO_NORETURN
0096 #define BOOST_STATIC_STRING_NORETURN __attribute__((__noreturn__))
0097 #endif
0098 
0099 // _MSVC_LANG isn't avaliable until after VS2015
0100 #if defined(_MSC_VER) && _MSC_VER < 1910L
0101 // The constexpr support in this version is effectively that of
0102 // c++11, so we treat it as such
0103 #define BOOST_STATIC_STRING_STANDARD_VERSION 201103L
0104 #elif defined(_MSVC_LANG)
0105 // MSVC doesn't define __cplusplus by default
0106 #define BOOST_STATIC_STRING_STANDARD_VERSION _MSVC_LANG
0107 #else
0108 #define BOOST_STATIC_STRING_STANDARD_VERSION __cplusplus
0109 #endif
0110 
0111 // Decide what level of constexpr we can use
0112 #define BOOST_STATIC_STRING_CPP20_CONSTEXPR
0113 #define BOOST_STATIC_STRING_CPP17_CONSTEXPR
0114 #define BOOST_STATIC_STRING_CPP14_CONSTEXPR
0115 #define BOOST_STATIC_STRING_CPP11_CONSTEXPR
0116 #if BOOST_STATIC_STRING_STANDARD_VERSION >= 202002L
0117 #define BOOST_STATIC_STRING_CPP20
0118 #undef BOOST_STATIC_STRING_CPP20_CONSTEXPR
0119 #define BOOST_STATIC_STRING_CPP20_CONSTEXPR constexpr
0120 #endif
0121 #if BOOST_STATIC_STRING_STANDARD_VERSION >= 201703L
0122 #define BOOST_STATIC_STRING_CPP17
0123 #undef BOOST_STATIC_STRING_CPP17_CONSTEXPR
0124 #define BOOST_STATIC_STRING_CPP17_CONSTEXPR constexpr
0125 #endif
0126 #if BOOST_STATIC_STRING_STANDARD_VERSION >= 201402L
0127 #define BOOST_STATIC_STRING_CPP14
0128 #undef BOOST_STATIC_STRING_CPP14_CONSTEXPR
0129 #define BOOST_STATIC_STRING_CPP14_CONSTEXPR constexpr
0130 #endif
0131 #if BOOST_STATIC_STRING_STANDARD_VERSION >= 201103L
0132 #define BOOST_STATIC_STRING_CPP11
0133 #undef BOOST_STATIC_STRING_CPP11_CONSTEXPR
0134 #define BOOST_STATIC_STRING_CPP11_CONSTEXPR constexpr
0135 #endif
0136 
0137 // Boost and non-Boost versions of utilities
0138 #ifndef BOOST_STATIC_STRING_STANDALONE
0139 #ifndef BOOST_STATIC_STRING_THROW
0140 #define BOOST_STATIC_STRING_THROW(ex) BOOST_THROW_EXCEPTION(ex)
0141 #endif
0142 #ifndef BOOST_STATIC_STRING_STATIC_ASSERT
0143 #define BOOST_STATIC_STRING_STATIC_ASSERT(cond, msg) BOOST_STATIC_ASSERT_MSG(cond, msg)
0144 #endif
0145 #ifndef BOOST_STATIC_STRING_ASSERT
0146 #define BOOST_STATIC_STRING_ASSERT(cond) BOOST_ASSERT(cond)
0147 #endif
0148 #else
0149 #ifndef BOOST_STATIC_STRING_THROW
0150 #define BOOST_STATIC_STRING_THROW(ex) throw ex
0151 #endif
0152 #ifndef BOOST_STATIC_STRING_STATIC_ASSERT
0153 #define BOOST_STATIC_STRING_STATIC_ASSERT(cond, msg) static_assert(cond, msg)
0154 #endif
0155 #ifndef BOOST_STATIC_STRING_ASSERT
0156 #define BOOST_STATIC_STRING_ASSERT(cond) assert(cond)
0157 #endif
0158 #endif
0159 
0160 #ifndef BOOST_STATIC_STRING_STANDALONE
0161 #include <boost/config.hpp>
0162 #include <boost/assert.hpp>
0163 #include <boost/container_hash/hash.hpp>
0164 #include <boost/static_assert.hpp>
0165 #include <boost/utility/string_view.hpp>
0166 #include <boost/core/detail/string_view.hpp>
0167 #include <boost/throw_exception.hpp>
0168 
0169 #if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW) || \
0170      defined(BOOST_STATIC_STRING_CXX17_STRING_VIEW)
0171 #include <string_view>
0172 #define BOOST_STATIC_STRING_HAS_STD_STRING_VIEW
0173 #endif
0174 #else
0175 #include <cassert>
0176 #include <stdexcept>
0177 
0178 /*
0179  * Replicate the logic from Boost.Config
0180  */
0181 // GNU libstdc++3:
0182 #if defined(__GLIBCPP__) || defined(__GLIBCXX__)
0183 #if (BOOST_LIBSTDCXX_VERSION < 70100) || (__cplusplus <= 201402L)
0184 #  define BOOST_STATIC_STRING_NO_CXX17_HDR_STRING_VIEW
0185 #endif
0186 // libc++:
0187 #elif defined(_LIBCPP_VERSION)
0188 #if (_LIBCPP_VERSION < 4000) || (__cplusplus <= 201402L)
0189 #  define BOOST_STATIC_STRING_NO_CXX17_HDR_STRING_VIEW
0190 #endif
0191 // MSVC uses logic from catch all for BOOST_NO_CXX17_HDR_STRING_VIEW
0192 // catch all:
0193 #elif !defined(_YVALS) && !defined(_CPPLIB_VER)
0194 #if (!defined(__has_include) || (__cplusplus < 201700))
0195 #  define BOOST_STATIC_STRING_NO_CXX17_HDR_STRING_VIEW
0196 #elif !__has_include(<string_view>)
0197 #  define BOOST_STATIC_STRING_NO_CXX17_HDR_STRING_VIEW
0198 #endif
0199 #endif
0200 
0201 #if !defined(BOOST_STATIC_STRING_NO_CXX17_HDR_STRING_VIEW) || \
0202      defined(BOOST_STATIC_STRING_CXX17_STRING_VIEW)
0203 #include <string_view>
0204 #define BOOST_STATIC_STRING_HAS_STD_STRING_VIEW
0205 #endif
0206 #endif
0207 
0208 // Compiler bug prevents constexpr from working with clang 4.x and 5.x
0209 // if it is detected, we disable constexpr.
0210 #if (BOOST_STATIC_STRING_STANDARD_VERSION >= 201402L && \
0211 BOOST_STATIC_STRING_STANDARD_VERSION < 201703L) && \
0212 defined(__clang__) && \
0213 ((__clang_major__ == 4) || (__clang_major__ == 5))
0214 // This directive works on clang
0215 #warning "C++14 constexpr is not supported in clang 4.x and 5.x due to a compiler bug."
0216 #ifdef BOOST_STATIC_STRING_CPP14
0217 #undef BOOST_STATIC_STRING_CPP14
0218 #endif
0219 #undef BOOST_STATIC_STRING_CPP14_CONSTEXPR
0220 #define BOOST_STATIC_STRING_CPP14_CONSTEXPR
0221 #endif
0222 
0223 // This is for compiler/library configurations
0224 // that cannot use the library comparison function
0225 // objects at all in constant expresssions. In these
0226 // cases, we use whatever will make more constexpr work.
0227 #if defined(__clang__) && \
0228 (defined(__GLIBCXX__) || defined(_MSC_VER))
0229 #define BOOST_STATIC_STRING_NO_PTR_COMP_FUNCTIONS
0230 #endif
0231 
0232 // In gcc-5, we cannot use throw expressions in a
0233 // constexpr function. However, we have a workaround
0234 // for this using constructors. Also, non-static member
0235 // functions that return the class they are a member of
0236 // causes an ICE during constant evaluation.
0237 #if defined(__GNUC__) && (__GNUC__== 5) && \
0238 defined(BOOST_STATIC_STRING_CPP14)
0239 #define BOOST_STATIC_STRING_GCC5_BAD_CONSTEXPR
0240 #endif
0241 
0242 #ifndef BOOST_STATIC_STRING_STANDALONE
0243 #if ! defined(BOOST_NO_CWCHAR) && ! defined(BOOST_NO_SWPRINTF)
0244 #define BOOST_STATIC_STRING_HAS_WCHAR
0245 #endif
0246 #else
0247 #ifndef __has_include
0248 // If we don't have __has_include in standalone,
0249 // we will assume that <cwchar> exists.
0250 #define BOOST_STATIC_STRING_HAS_WCHAR
0251 #elif __has_include(<cwchar>)
0252 #define BOOST_STATIC_STRING_HAS_WCHAR
0253 #endif
0254 #endif
0255 
0256 #ifdef BOOST_STATIC_STRING_HAS_WCHAR
0257 #include <cwchar>
0258 #endif
0259 
0260 // Define the basic string_view type used by the library
0261 // Conversions to and from other available string_view types
0262 // are still defined.
0263 #if !defined(BOOST_STATIC_STRING_STANDALONE) || \
0264      defined(BOOST_STATIC_STRING_HAS_STD_STRING_VIEW)
0265 #define BOOST_STATIC_STRING_HAS_ANY_STRING_VIEW
0266 namespace boost {
0267 namespace static_strings {
0268 
0269 /// The type of `basic_string_view` used by the library
0270 template<typename CharT, typename Traits>
0271 using basic_string_view =
0272 #ifndef BOOST_STATIC_STRING_STANDALONE
0273   boost::basic_string_view<CharT, Traits>;
0274 #else
0275   std::basic_string_view<CharT, Traits>;
0276 #endif
0277 } // static_strings
0278 } // boost
0279 #endif
0280 
0281 #endif