From fda558e034433fe96d27ca2604ad34bf1b1ef4d6 Mon Sep 17 00:00:00 2001 From: Richard Hodges Date: Thu, 30 Apr 2020 17:11:05 +0200 Subject: [PATCH] Fix standalone compilation error with std::string_view fixes #1913 --- CHANGELOG.md | 1 + include/boost/beast/http/field.hpp | 7 ++----- include/boost/beast/http/impl/field.ipp | 10 +++++++++- test/beast/http/CMakeLists.txt | 1 + test/beast/http/Jamfile | 1 + test/beast/http/field_compiles.cpp | 11 +++++++++++ 6 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 test/beast/http/field_compiles.cpp diff --git a/CHANGELOG.md b/CHANGELOG.md index f8150527..13f5d8c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ +* Fix standalone compilation error with std::string_view * OpenSSL 1.0.2 or later is required * Fix c++20 deprecation warning in span_body diff --git a/include/boost/beast/http/field.hpp b/include/boost/beast/http/field.hpp index 69eb253f..3f943647 100644 --- a/include/boost/beast/http/field.hpp +++ b/include/boost/beast/http/field.hpp @@ -396,12 +396,9 @@ field string_to_field(string_view s); /// Write the text for a field name to an output stream. -inline +BOOST_BEAST_DECL std::ostream& -operator<<(std::ostream& os, field f) -{ - return os << to_string(f); -} +operator<<(std::ostream& os, field f); } // http } // beast diff --git a/include/boost/beast/http/impl/field.ipp b/include/boost/beast/http/impl/field.ipp index 94ff1fa9..f25be99b 100644 --- a/include/boost/beast/http/impl/field.ipp +++ b/include/boost/beast/http/impl/field.ipp @@ -11,10 +11,12 @@ #define BOOST_BEAST_HTTP_IMPL_FIELD_IPP #include +#include #include #include #include -#include +#include + namespace boost { namespace beast { @@ -565,6 +567,12 @@ string_to_field(string_view s) return detail::get_field_table().string_to_field(s); } +std::ostream& +operator<<(std::ostream& os, field f) +{ + return os << to_string(f); +} + } // http } // beast } // boost diff --git a/test/beast/http/CMakeLists.txt b/test/beast/http/CMakeLists.txt index ac48fd36..11fcf591 100644 --- a/test/beast/http/CMakeLists.txt +++ b/test/beast/http/CMakeLists.txt @@ -26,6 +26,7 @@ add_executable (tests-beast-http empty_body.cpp error.cpp field.cpp + field_compiles.cpp fields.cpp file_body.cpp message.cpp diff --git a/test/beast/http/Jamfile b/test/beast/http/Jamfile index f96155d6..4bde0939 100644 --- a/test/beast/http/Jamfile +++ b/test/beast/http/Jamfile @@ -16,6 +16,7 @@ local SOURCES = dynamic_body.cpp error.cpp field.cpp + field_compiles.cpp fields.cpp file_body.cpp message.cpp diff --git a/test/beast/http/field_compiles.cpp b/test/beast/http/field_compiles.cpp new file mode 100644 index 00000000..4834b768 --- /dev/null +++ b/test/beast/http/field_compiles.cpp @@ -0,0 +1,11 @@ +// +// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// 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/beast +// + +// Test that header file is self-contained. +#include