2
0
mirror of https://github.com/boostorg/pfr.git synced 2026-01-19 04:22:13 +00:00

relax standard library requirements

This commit is contained in:
Antony Polukhin
2023-09-17 13:41:43 +03:00
parent 6dcf66cbd5
commit 3f07e7187e
2 changed files with 13 additions and 8 deletions

View File

@@ -22,7 +22,6 @@
#include <type_traits>
#include <string_view>
#include <array>
#include <algorithm> // for std::ranges::copy
#include <memory> // for std::addressof
namespace boost { namespace pfr { namespace detail {
@@ -138,7 +137,13 @@ consteval auto name_of_field_impl() noexcept {
constexpr auto fn = skip.apply(sv);
auto res = std::array<char, fn.size()+1>{};
detail::assert_compile_time_legths<!fn.empty()>();
std::ranges::copy(fn, res.begin());
auto* out = res.begin();
for (auto x: fn) {
*out = x;
++out;
}
return res;
}
}

View File

@@ -29,12 +29,12 @@ static_assert(boost::pfr::get_name<1, Aggregate>() == "this_is_a_name");
static_assert(boost::pfr::get_name<2, Aggregate>() == "c");
static_assert(boost::pfr::get_name<3, Aggregate>() == "Forth");
static_assert(boost::pfr::names_as_array<Aggregate>() == std::array<std::string_view, 4>{
"member1",
"this_is_a_name",
"c",
"Forth"
});
constexpr auto names_array = boost::pfr::names_as_array<Aggregate>();
static_assert(names_array.size() == 4);
static_assert(names_array[0] == "member1");
static_assert(names_array[1] == "this_is_a_name");
static_assert(names_array[2] == "c");
static_assert(names_array[3] == "Forth");
int main() {}