Replaced C++20 feature test macros by Boost.Config's for C++17 headers

This commit is contained in:
Anarthal (Rubén Pérez) 2025-02-13 08:03:57 +01:00 committed by GitHub
parent 6a24faa7da
commit cd0ee4ad14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 25 additions and 25 deletions

View File

@ -44,7 +44,6 @@ docca.pyreference reference.qbk
<doxygen:param>STRIP_FROM_PATH=$(include-prefix)
<doxygen:param>"PREDEFINED=\\
BOOST_MYSQL_DOXYGEN \\
__cpp_lib_string_view \\
__cpp_char8_t \\
\"BOOST_PFR_ENABLED=1\" \\
\"BOOST_PFR_CORE_NAME_ENABLED=1\" \\

View File

@ -16,12 +16,13 @@
#include <boost/mysql/detail/config.hpp>
#include <boost/mysql/detail/field_impl.hpp>
#include <boost/config.hpp>
#include <boost/variant2/variant.hpp>
#include <cstddef>
#include <iosfwd>
#include <string>
#ifdef __cpp_lib_string_view
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
#include <string_view>
#endif
@ -187,7 +188,7 @@ public:
/// \copydoc field(const std::string&)
explicit field(string_view v) : repr_(boost::variant2::in_place_type_t<std::string>(), v) {}
#if defined(__cpp_lib_string_view)
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
/// \copydoc field(const std::string&)
explicit field(std::string_view v) : repr_(boost::variant2::in_place_type_t<std::string>(), v) {}
#endif
@ -412,7 +413,7 @@ public:
return *this;
}
#if defined(__cpp_lib_string_view)
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
/// \copydoc operator=(const std::string&)
field& operator=(std::string_view v)
{

View File

@ -35,7 +35,7 @@
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
#include <optional>
#endif
#ifdef __cpp_lib_polymorphic_allocator
#ifndef BOOST_NO_CXX17_HDR_MEMORY_RESOURCE
#include <memory_resource>
#endif
#ifdef BOOST_MYSQL_HAS_RANGES
@ -717,7 +717,7 @@ BOOST_AUTO_TEST_CASE(section_sql_formatting)
// res.value() would throw an error, like format_sql would
//]
}
#ifdef __cpp_lib_polymorphic_allocator
#ifndef BOOST_NO_CXX17_HDR_MEMORY_RESOURCE
{
//[sql_formatting_custom_string
// Create a format context that uses std::pmr::string

View File

@ -12,7 +12,7 @@
#include <boost/test/unit_test.hpp>
#ifdef __cpp_lib_string_view
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
#include <string_view>
#endif
@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(ctor_string_view)
}
#endif
#ifdef __cpp_lib_string_view
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
BOOST_AUTO_TEST_CASE(ctor_std_string_view)
{
constexpr std::string_view s = "abcd";
@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE(runtime_string)
BOOST_TEST(f(runtime(s)) == "abc");
}
#ifdef __cpp_lib_string_view
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
BOOST_AUTO_TEST_CASE(runtime_std_string_view)
{
std::string_view s = "abc";

View File

@ -131,7 +131,7 @@ static_assert(is_writable_field<std::string>::value, "");
static_assert(is_writable_field<string_with_alloc>::value, "");
static_assert(is_writable_field<string_no_defctor>::value, "");
static_assert(is_writable_field<string_view>::value, "");
#ifdef __cpp_lib_string_view
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
static_assert(is_writable_field<std::string_view>::value, "");
#endif
static_assert(!is_writable_field<string_with_traits>::value, "");
@ -310,7 +310,7 @@ BOOST_AUTO_TEST_CASE(to_field_)
BOOST_TEST(to_field(s) == field_view("ljk"));
BOOST_TEST(to_field(static_cast<const std::string&>(s)) == field_view("ljk"));
BOOST_TEST(to_field(string_view("abc")) == field_view("abc"));
#if defined(__cpp_lib_string_view)
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
BOOST_TEST(to_field(std::string_view("abc")) == field_view("abc"));
#endif
BOOST_TEST(to_field(static_cast<const char*>("abc")) == field_view("abc"));

View File

@ -144,7 +144,7 @@ BOOST_AUTO_TEST_CASE(from_boost_string_view)
BOOST_TEST(v.as_string() == "test");
}
#ifdef __cpp_lib_string_view
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
BOOST_AUTO_TEST_CASE(from_std_string_view)
{
std::string_view sv("test123", 4);
@ -433,7 +433,7 @@ BOOST_AUTO_TEST_CASE(from_boost_string_view)
BOOST_TEST(v.as_string() == "test");
}
#ifdef __cpp_lib_string_view
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
BOOST_AUTO_TEST_CASE(from_std_string_view)
{
std::string_view sv("test123", 4);

View File

@ -25,10 +25,10 @@
#include "format_common.hpp"
#include "test_common/has_ranges.hpp"
#ifdef __cpp_lib_string_view
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
#include <string_view>
#endif
#ifdef __cpp_lib_optional
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
#include <optional>
#endif
#ifdef BOOST_MYSQL_HAS_RANGES
@ -94,7 +94,7 @@ BOOST_MYSQL_CHECK_FORMATTABLE(const char, false)
BOOST_MYSQL_CHECK_FORMATTABLE(std::string, true)
BOOST_MYSQL_CHECK_FORMATTABLE(string_with_alloc, true)
BOOST_MYSQL_CHECK_FORMATTABLE(string_view, true)
#ifdef __cpp_lib_string_view
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
BOOST_MYSQL_CHECK_FORMATTABLE(std::string_view, true)
#endif
BOOST_MYSQL_CHECK_FORMATTABLE(const char*, true)

View File

@ -29,10 +29,10 @@
#include "test_common/create_basic.hpp"
#include "test_common/printing.hpp"
#ifdef __cpp_lib_string_view
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
#include <string_view>
#endif
#ifdef __cpp_lib_optional
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
#include <optional>
#endif
@ -278,7 +278,7 @@ BOOST_AUTO_TEST_CASE(string_view_)
BOOST_TEST(format_sql(opts, identifier_fmt, string_view("abc")) == "SELECT `abc` FROM myt");
}
#ifdef __cpp_lib_string_view
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
BOOST_AUTO_TEST_CASE(std_string_view)
{
BOOST_TEST(format_sql(opts, single_fmt, std::string_view("abc")) == "SELECT 'abc';");
@ -486,7 +486,7 @@ BOOST_AUTO_TEST_CASE(boost_optional)
BOOST_TEST(format_sql(opts, single_fmt, co_clval) == "SELECT 'abdef';");
}
#ifdef __cpp_lib_optional
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
BOOST_AUTO_TEST_CASE(std_optional)
{
std::optional<std::string> o_lval("abc");
@ -681,7 +681,7 @@ void optional_error_test()
BOOST_AUTO_TEST_CASE(boost_optional_error) { optional_error_test<boost::optional>(); }
#ifdef __cpp_lib_optional
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
BOOST_AUTO_TEST_CASE(std_optional_error) { optional_error_test<std::optional>(); }
#endif

View File

@ -25,10 +25,10 @@
#include "test_common/has_ranges.hpp"
#include "test_common/printing.hpp"
#ifdef __cpp_lib_string_view
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
#include <string_view>
#endif
#ifdef __cpp_lib_optional
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
#include <optional>
#endif
#ifdef BOOST_MYSQL_HAS_RANGES
@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE(elm_string)
BOOST_TEST(
format_sql(opts, single_fmt, std::vector<string_view>{"abc", "buf"}) == "SELECT 'abc', 'buf';"
);
#ifdef __cpp_lib_string_view
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
BOOST_TEST(
format_sql(opts, single_fmt, std::vector<std::string_view>{"abc", "buf"}) == "SELECT 'abc', 'buf';"
);
@ -159,7 +159,7 @@ BOOST_AUTO_TEST_CASE(elm_boost_optional)
BOOST_TEST(format_sql(opts, single_fmt, optionals) == "SELECT 42, 10, NULL;");
}
#ifdef __cpp_lib_optional
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
BOOST_AUTO_TEST_CASE(elm_std_optional)
{
std::vector<std::optional<std::string>> optionals{"abc", {}, "d"};