Skip to content

Commit

Permalink
Use string_ref in older Boost versions
Browse files Browse the repository at this point in the history
  • Loading branch information
vinniefalco committed Jul 20, 2017
1 parent 43f8bb8 commit 64ff766
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ env:
# to boost's .tar.gz.
- LCOV_ROOT=$HOME/lcov
- VALGRIND_ROOT=$HOME/valgrind-install
- BOOST_ROOT=$HOME/boost_1_64_0
- BOOST_URL='http://sourceforge.net/projects/boost/files/boost/1.64.0/boost_1_64_0.tar.gz'
- BOOST_ROOT=$HOME/boost_1_58_0
- BOOST_URL='http://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.gz'

addons:
apt:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Version 68:
* Split common tests to a new project
* Small speed up in fields comparisons
* Adjust buffer size in fast server
* Use string_ref in older Boost versions

API Changes:

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ endif()
option (Boost_USE_STATIC_LIBS "Use static libraries for boost" ON)

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})

Expand Down
24 changes: 24 additions & 0 deletions include/beast/core/string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,42 @@
#ifndef 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>
#endif

#include <algorithm>

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
using string_view = boost::string_view;

/// The type of basic string view used by the library
template<class CharT, class Traits>
using basic_string_view =
boost::basic_string_view<CharT, Traits>;
#endif

namespace detail {

Expand Down

0 comments on commit 64ff766

Please sign in to comment.