Skip to content

Commit cd0ee4a

Browse files
authored
Replaced C++20 feature test macros by Boost.Config's for C++17 headers
1 parent 6a24faa commit cd0ee4a

File tree

9 files changed

+25
-25
lines changed

9 files changed

+25
-25
lines changed

doc/Jamfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ docca.pyreference reference.qbk
4444
<doxygen:param>STRIP_FROM_PATH=$(include-prefix)
4545
<doxygen:param>"PREDEFINED=\\
4646
BOOST_MYSQL_DOXYGEN \\
47-
__cpp_lib_string_view \\
4847
__cpp_char8_t \\
4948
\"BOOST_PFR_ENABLED=1\" \\
5049
\"BOOST_PFR_CORE_NAME_ENABLED=1\" \\

include/boost/mysql/field.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
#include <boost/mysql/detail/config.hpp>
1717
#include <boost/mysql/detail/field_impl.hpp>
1818

19+
#include <boost/config.hpp>
1920
#include <boost/variant2/variant.hpp>
2021

2122
#include <cstddef>
2223
#include <iosfwd>
2324
#include <string>
24-
#ifdef __cpp_lib_string_view
25+
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
2526
#include <string_view>
2627
#endif
2728

@@ -187,7 +188,7 @@ class field
187188
/// \copydoc field(const std::string&)
188189
explicit field(string_view v) : repr_(boost::variant2::in_place_type_t<std::string>(), v) {}
189190

190-
#if defined(__cpp_lib_string_view)
191+
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
191192
/// \copydoc field(const std::string&)
192193
explicit field(std::string_view v) : repr_(boost::variant2::in_place_type_t<std::string>(), v) {}
193194
#endif
@@ -412,7 +413,7 @@ class field
412413
return *this;
413414
}
414415

415-
#if defined(__cpp_lib_string_view)
416+
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
416417
/// \copydoc operator=(const std::string&)
417418
field& operator=(std::string_view v)
418419
{

test/integration/test/snippets/sql_formatting.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
3636
#include <optional>
3737
#endif
38-
#ifdef __cpp_lib_polymorphic_allocator
38+
#ifndef BOOST_NO_CXX17_HDR_MEMORY_RESOURCE
3939
#include <memory_resource>
4040
#endif
4141
#ifdef BOOST_MYSQL_HAS_RANGES
@@ -717,7 +717,7 @@ BOOST_AUTO_TEST_CASE(section_sql_formatting)
717717
// res.value() would throw an error, like format_sql would
718718
//]
719719
}
720-
#ifdef __cpp_lib_polymorphic_allocator
720+
#ifndef BOOST_NO_CXX17_HDR_MEMORY_RESOURCE
721721
{
722722
//[sql_formatting_custom_string
723723
// Create a format context that uses std::pmr::string

test/unit/test/constant_string_view.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include <boost/test/unit_test.hpp>
1414

15-
#ifdef __cpp_lib_string_view
15+
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
1616
#include <string_view>
1717
#endif
1818

@@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(ctor_string_view)
3434
}
3535
#endif
3636

37-
#ifdef __cpp_lib_string_view
37+
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
3838
BOOST_AUTO_TEST_CASE(ctor_std_string_view)
3939
{
4040
constexpr std::string_view s = "abcd";
@@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE(runtime_string)
8484
BOOST_TEST(f(runtime(s)) == "abc");
8585
}
8686

87-
#ifdef __cpp_lib_string_view
87+
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
8888
BOOST_AUTO_TEST_CASE(runtime_std_string_view)
8989
{
9090
std::string_view s = "abc";

test/unit/test/detail/writable_field_traits.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static_assert(is_writable_field<std::string>::value, "");
131131
static_assert(is_writable_field<string_with_alloc>::value, "");
132132
static_assert(is_writable_field<string_no_defctor>::value, "");
133133
static_assert(is_writable_field<string_view>::value, "");
134-
#ifdef __cpp_lib_string_view
134+
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
135135
static_assert(is_writable_field<std::string_view>::value, "");
136136
#endif
137137
static_assert(!is_writable_field<string_with_traits>::value, "");
@@ -310,7 +310,7 @@ BOOST_AUTO_TEST_CASE(to_field_)
310310
BOOST_TEST(to_field(s) == field_view("ljk"));
311311
BOOST_TEST(to_field(static_cast<const std::string&>(s)) == field_view("ljk"));
312312
BOOST_TEST(to_field(string_view("abc")) == field_view("abc"));
313-
#if defined(__cpp_lib_string_view)
313+
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
314314
BOOST_TEST(to_field(std::string_view("abc")) == field_view("abc"));
315315
#endif
316316
BOOST_TEST(to_field(static_cast<const char*>("abc")) == field_view("abc"));

test/unit/test/field.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ BOOST_AUTO_TEST_CASE(from_boost_string_view)
144144
BOOST_TEST(v.as_string() == "test");
145145
}
146146

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

436-
#ifdef __cpp_lib_string_view
436+
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
437437
BOOST_AUTO_TEST_CASE(from_std_string_view)
438438
{
439439
std::string_view sv("test123", 4);

test/unit/test/format_sql/formattable.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
#include "format_common.hpp"
2626
#include "test_common/has_ranges.hpp"
2727

28-
#ifdef __cpp_lib_string_view
28+
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
2929
#include <string_view>
3030
#endif
31-
#ifdef __cpp_lib_optional
31+
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
3232
#include <optional>
3333
#endif
3434
#ifdef BOOST_MYSQL_HAS_RANGES
@@ -94,7 +94,7 @@ BOOST_MYSQL_CHECK_FORMATTABLE(const char, false)
9494
BOOST_MYSQL_CHECK_FORMATTABLE(std::string, true)
9595
BOOST_MYSQL_CHECK_FORMATTABLE(string_with_alloc, true)
9696
BOOST_MYSQL_CHECK_FORMATTABLE(string_view, true)
97-
#ifdef __cpp_lib_string_view
97+
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
9898
BOOST_MYSQL_CHECK_FORMATTABLE(std::string_view, true)
9999
#endif
100100
BOOST_MYSQL_CHECK_FORMATTABLE(const char*, true)

test/unit/test/format_sql/individual_value.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
#include "test_common/create_basic.hpp"
3030
#include "test_common/printing.hpp"
3131

32-
#ifdef __cpp_lib_string_view
32+
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
3333
#include <string_view>
3434
#endif
35-
#ifdef __cpp_lib_optional
35+
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
3636
#include <optional>
3737
#endif
3838

@@ -278,7 +278,7 @@ BOOST_AUTO_TEST_CASE(string_view_)
278278
BOOST_TEST(format_sql(opts, identifier_fmt, string_view("abc")) == "SELECT `abc` FROM myt");
279279
}
280280

281-
#ifdef __cpp_lib_string_view
281+
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
282282
BOOST_AUTO_TEST_CASE(std_string_view)
283283
{
284284
BOOST_TEST(format_sql(opts, single_fmt, std::string_view("abc")) == "SELECT 'abc';");
@@ -486,7 +486,7 @@ BOOST_AUTO_TEST_CASE(boost_optional)
486486
BOOST_TEST(format_sql(opts, single_fmt, co_clval) == "SELECT 'abdef';");
487487
}
488488

489-
#ifdef __cpp_lib_optional
489+
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
490490
BOOST_AUTO_TEST_CASE(std_optional)
491491
{
492492
std::optional<std::string> o_lval("abc");
@@ -681,7 +681,7 @@ void optional_error_test()
681681

682682
BOOST_AUTO_TEST_CASE(boost_optional_error) { optional_error_test<boost::optional>(); }
683683

684-
#ifdef __cpp_lib_optional
684+
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
685685
BOOST_AUTO_TEST_CASE(std_optional_error) { optional_error_test<std::optional>(); }
686686
#endif
687687

test/unit/test/format_sql/ranges.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
#include "test_common/has_ranges.hpp"
2626
#include "test_common/printing.hpp"
2727

28-
#ifdef __cpp_lib_string_view
28+
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
2929
#include <string_view>
3030
#endif
31-
#ifdef __cpp_lib_optional
31+
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
3232
#include <optional>
3333
#endif
3434
#ifdef BOOST_MYSQL_HAS_RANGES
@@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE(elm_string)
8888
BOOST_TEST(
8989
format_sql(opts, single_fmt, std::vector<string_view>{"abc", "buf"}) == "SELECT 'abc', 'buf';"
9090
);
91-
#ifdef __cpp_lib_string_view
91+
#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
9292
BOOST_TEST(
9393
format_sql(opts, single_fmt, std::vector<std::string_view>{"abc", "buf"}) == "SELECT 'abc', 'buf';"
9494
);
@@ -159,7 +159,7 @@ BOOST_AUTO_TEST_CASE(elm_boost_optional)
159159
BOOST_TEST(format_sql(opts, single_fmt, optionals) == "SELECT 42, 10, NULL;");
160160
}
161161

162-
#ifdef __cpp_lib_optional
162+
#ifndef BOOST_NO_CXX17_HDR_OPTIONAL
163163
BOOST_AUTO_TEST_CASE(elm_std_optional)
164164
{
165165
std::vector<std::optional<std::string>> optionals{"abc", {}, "d"};

0 commit comments

Comments
 (0)