Use string_ref in older Boost versions

fix #543
This commit is contained in:
Vinnie Falco
2017-06-26 09:00:15 -07:00
parent 43f8bb841a
commit 64ff766b23
4 changed files with 28 additions and 3 deletions

View File

@@ -11,8 +11,8 @@ env:
# to boost's .tar.gz. # to boost's .tar.gz.
- LCOV_ROOT=$HOME/lcov - LCOV_ROOT=$HOME/lcov
- VALGRIND_ROOT=$HOME/valgrind-install - VALGRIND_ROOT=$HOME/valgrind-install
- BOOST_ROOT=$HOME/boost_1_64_0 - BOOST_ROOT=$HOME/boost_1_58_0
- BOOST_URL='http://sourceforge.net/projects/boost/files/boost/1.64.0/boost_1_64_0.tar.gz' - BOOST_URL='http://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.gz'
addons: addons:
apt: apt:

View File

@@ -3,6 +3,7 @@ Version 68:
* Split common tests to a new project * Split common tests to a new project
* Small speed up in fields comparisons * Small speed up in fields comparisons
* Adjust buffer size in fast server * Adjust buffer size in fast server
* Use string_ref in older Boost versions
API Changes: API Changes:

View File

@@ -48,7 +48,7 @@ endif()
option (Boost_USE_STATIC_LIBS "Use static libraries for boost" ON) option (Boost_USE_STATIC_LIBS "Use static libraries for boost" ON)
set (BOOST_COMPONENTS coroutine context filesystem program_options system thread) set (BOOST_COMPONENTS coroutine context filesystem program_options system thread)
find_package (Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS}) find_package (Boost 1.58.0 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
link_directories(${Boost_LIBRARY_DIRS}) link_directories(${Boost_LIBRARY_DIRS})

View File

@@ -8,11 +8,34 @@
#ifndef BEAST_STRING_HPP #ifndef BEAST_STRING_HPP
#define BEAST_STRING_HPP #define BEAST_STRING_HPP
#include <boost/version.hpp>
#ifndef BEAST_NO_BOOST_STRING_VIEW
# if BOOST_VERSION >= 106400
# define BEAST_NO_BOOST_STRING_VIEW 0
# else
# define BEAST_NO_BOOST_STRING_VIEW 1
# endif
#endif
#if BEAST_NO_BOOST_STRING_VIEW
#include <boost/utility/string_ref.hpp>
#else
#include <boost/utility/string_view.hpp> #include <boost/utility/string_view.hpp>
#endif
#include <algorithm> #include <algorithm>
namespace beast { namespace beast {
#if BEAST_NO_BOOST_STRING_VIEW
/// The type of string view used by the library
using string_view = boost::string_ref;
/// The type of basic string view used by the library
template<class CharT, class Traits>
using basic_string_view =
boost::basic_string_ref<CharT, Traits>;
#else
/// The type of string view used by the library /// The type of string view used by the library
using string_view = boost::string_view; using string_view = boost::string_view;
@@ -20,6 +43,7 @@ using string_view = boost::string_view;
template<class CharT, class Traits> template<class CharT, class Traits>
using basic_string_view = using basic_string_view =
boost::basic_string_view<CharT, Traits>; boost::basic_string_view<CharT, Traits>;
#endif
namespace detail { namespace detail {