Skip to content

Commit

Permalink
string_view interoperability
Browse files Browse the repository at this point in the history
  • Loading branch information
alandefreitas committed Jan 12, 2023
1 parent 0c914ff commit b1a1b7a
Show file tree
Hide file tree
Showing 4 changed files with 675 additions and 65 deletions.
27 changes: 27 additions & 0 deletions include/boost/static_string/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,34 @@
#endif

#ifndef BOOST_STATIC_STRING_STANDALONE
#include <boost/config.hpp>
#include <boost/assert.hpp>
#include <boost/container_hash/hash.hpp>
#include <boost/static_assert.hpp>
#include <boost/utility/string_view.hpp>
#include <boost/core/detail/string_view.hpp>
#include <boost/throw_exception.hpp>
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW) && \
!defined(BOOST_STATIC_STRING_CXX17_STRING_VIEW)
#define BOOST_STATIC_STRING_CXX17_STRING_VIEW
#endif
#else
#include <cassert>
#include <stdexcept>
#endif

// Include std::string_view
#if defined(BOOST_STATIC_STRING_CXX17_STRING_VIEW) || __cplusplus >= 201703L
#include <string_view>
#elif defined(__has_include)
#if __has_include(<string_view>)
#include <string_view>
#endif
#endif

// Determine if the class (and not only the header) is available
#if __cpp_lib_string_view >= 201606L
#define BOOST_STATIC_STRING_HAS_STD_STRING_VIEW
#endif

// Compiler bug prevents constexpr from working with clang 4.x and 5.x
Expand Down Expand Up @@ -192,6 +211,12 @@ defined(BOOST_STATIC_STRING_CPP14)
#define BOOST_STATIC_STRING_GCC5_BAD_CONSTEXPR
#endif

// Define the basic string_view type used by the library
// Conversions to and from other available string_view types
// are still defined.
#if !defined(BOOST_STATIC_STRING_STANDALONE) || \
defined(BOOST_STATIC_STRING_HAS_STD_STRING_VIEW)
#define BOOST_STATIC_STRING_HAS_STRING_VIEW
namespace boost {
namespace static_strings {

Expand All @@ -205,4 +230,6 @@ using basic_string_view =
#endif
} // static_strings
} // boost
#endif

#endif
Loading

0 comments on commit b1a1b7a

Please sign in to comment.