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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user