Files
boost_static_string/include/boost/fixed_string/config.hpp

89 lines
2.3 KiB
C++
Raw Normal View History

2019-09-09 13:56:14 -07:00
//
// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
2019-11-06 18:58:22 -05:00
// Copyright (c) 2019 Krystian Stasiowski (sdkrystian at gmail dot com)
2019-09-09 13:56:14 -07:00
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/fixed_string
//
#ifndef BOOST_FIXED_STRING_CONFIG_HPP
#define BOOST_FIXED_STRING_CONFIG_HPP
2019-10-27 19:40:29 -04:00
// Are we dependent on Boost?
2019-10-27 21:01:44 -04:00
#define BOOST_FIXED_STRING_USE_BOOST
2019-10-27 16:12:06 -04:00
// Can we have deduction guides?
#ifdef __cpp_deduction_guides
#define BOOST_FIXED_STRING_USE_DEDUCT
2019-10-27 16:12:06 -04:00
#endif
// Can we use [[nodiscard]]?
#ifdef __has_attribute
#if __has_attribute(nodiscard)
#define BOOST_FIXED_STRING_NODISCARD [[nodiscard]]
#else
#define BOOST_FIXED_STRING_NODISCARD
2019-10-27 16:12:06 -04:00
#endif
#else
#define BOOST_FIXED_STRING_NODISCARD
#endif
2019-10-27 16:12:06 -04:00
#ifdef BOOST_FIXED_STRING_USE_BOOST
2019-09-09 13:56:14 -07:00
#include <boost/utility/string_view.hpp>
2019-10-27 19:40:29 -04:00
#include <boost/assert.hpp>
#include <boost/static_assert.hpp>
#include <boost/throw_exception.hpp>
#else
#include <cassert>
2019-10-27 16:12:06 -04:00
#include <string_view>
#endif
2019-10-27 19:40:29 -04:00
// Boost and non-Boost versions of utilities
#ifdef BOOST_FIXED_STRING_USE_BOOST
#ifndef BOOST_FIXED_STRING_THROW
2019-10-27 19:40:29 -04:00
#define BOOST_FIXED_STRING_THROW(ex) BOOST_THROW_EXCEPTION(ex)
#endif
#ifndef BOOST_FIXED_STRING_STATIC_ASSERT
2019-10-27 19:40:29 -04:00
#define BOOST_FIXED_STRING_STATIC_ASSERT(cond, msg) BOOST_STATIC_ASSERT_MSG(cond, msg)
#endif
#ifndef BOOST_FIXED_STRING_ASSERT
2019-10-27 19:40:29 -04:00
#define BOOST_FIXED_STRING_ASSERT(cond) BOOST_ASSERT(cond)
#endif
2019-10-27 19:40:29 -04:00
#else
#ifndef BOOST_FIXED_STRING_THROW
2019-10-27 19:40:29 -04:00
#define BOOST_FIXED_STRING_THROW(ex) throw ex
#endif
#ifndef BOOST_FIXED_STRING_STATIC_ASSERT
2019-10-27 19:40:29 -04:00
#define BOOST_FIXED_STRING_STATIC_ASSERT(cond, msg) static_assert(cond, msg)
#endif
#ifndef BOOST_FIXED_STRING_ASSERT
2019-10-27 19:40:29 -04:00
#define BOOST_FIXED_STRING_ASSERT(cond) assert(cond)
#endif
#endif
2019-09-09 13:56:14 -07:00
namespace boost {
namespace fixed_string {
/// The type of `string_view` used by the library
2019-10-27 16:12:06 -04:00
using string_view =
#ifdef BOOST_FIXED_STRING_USE_BOOST
boost::string_view;
#else
std::string_view;
#endif
2019-09-09 13:56:14 -07:00
/// The type of `basic_string_view` used by the library
2019-09-13 14:27:09 -07:00
template<typename CharT, typename Traits>
2019-09-09 13:56:14 -07:00
using basic_string_view =
2019-10-27 16:12:06 -04:00
#ifdef BOOST_FIXED_STRING_USE_BOOST
2019-09-09 13:56:14 -07:00
boost::basic_string_view<CharT, Traits>;
2019-10-27 16:12:06 -04:00
#else
std::basic_string_view<CharT, Traits>;
#endif
2019-09-09 13:56:14 -07:00
} // fixed_string
} // boost
#endif