Back to requiring a string_view implementation

This commit is contained in:
Krystian Stasiowski
2019-10-28 23:48:11 -04:00
parent 5c81f47f7f
commit 1a65754a1f
4 changed files with 13 additions and 109 deletions

View File

@ -13,18 +13,16 @@
// Are we dependent on Boost?
#define BOOST_FIXED_STRING_USE_BOOST
// C++ version
#if __cplusplus >= 201703L
#define BOOST_FIXED_STRING_CPP17
#elif __cplusplus >= 201402L
#define BOOST_FIXED_STRING_CPP14
#else
#define BOOST_FIXED_STRING_CPP11
// Can we have deduction guides?
#ifdef __cpp_deduction_guides
#define BOOST_FIXED_STRING_USE_DEDUCT
#endif
// See if we can use `string_view`
#if defined(BOOST_FIXED_STRING_CPP17) || defined(BOOST_FIXED_STRING_USE_BOOST)
#define BOOST_FIXED_STRING_STRING_VIEW
// Can we use [[nodiscard]]?
#if __has_attribute(nodiscard)
#define BOOST_FIXED_STRING_NODISCARD [[nodiscard]]
#else
#define BOOST_FIXED_STRING_NODISCARD
#endif
#ifdef BOOST_FIXED_STRING_USE_BOOST
@ -34,47 +32,32 @@
#include <boost/throw_exception.hpp>
#else
#include <cassert>
#ifdef BOOST_FIXED_STRING_CPP17
#include <string_view>
#endif
#endif
// Boost and non-Boost versions of utilities
#ifdef BOOST_FIXED_STRING_USE_BOOST
#define BOOST_FIXED_STRING_THROW(ex) BOOST_THROW_EXCEPTION(ex)
#define BOOST_FIXED_STRING_STATIC_ASSERT(cond, msg) BOOST_STATIC_ASSERT_MSG(cond, msg)
#define BOOST_FIXED_STRING_ASSERT(cond) BOOST_ASSERT(cond)
#ifdef BOOST_NODISCARD
#define BOOST_FIXED_STRING_NODISCARD BOOST_NODISCARD
#else
#define BOOST_FIXED_STRING_NODISCARD
#endif
#else
#define BOOST_FIXED_STRING_THROW(ex) throw ex
#define BOOST_FIXED_STRING_STATIC_ASSERT(cond, msg) static_assert(cond, msg)
#define BOOST_FIXED_STRING_ASSERT(cond) assert(cond)
#ifdef BOOST_FIXED_STRING_CPP17
#define BOOST_FIXED_STRING_NODISCARD [[nodiscard]]
#else
#define BOOST_FIXED_STRING_NODISCARD
#endif
#endif
namespace boost {
namespace fixed_string {
/// The type of `string_view` used by the library
#ifdef BOOST_FIXED_STRING_STRING_VIEW
using string_view =
#ifdef BOOST_FIXED_STRING_USE_BOOST
boost::string_view;
#else
std::string_view;
#endif
#endif
/// The type of `basic_string_view` used by the library
#ifdef BOOST_FIXED_STRING_STRING_VIEW
template<typename CharT, typename Traits>
using basic_string_view =
#ifdef BOOST_FIXED_STRING_USE_BOOST
@ -82,7 +65,6 @@ using basic_string_view =
#else
std::basic_string_view<CharT, Traits>;
#endif
#endif
} // fixed_string
} // boost