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

Update member_to_index.cpp

This commit is contained in:
Antony Polukhin
2026-01-06 21:10:06 +03:00
committed by GitHub
parent 93d02b86ce
commit c951f22eb7

View File

@@ -5,6 +5,7 @@
#include <boost/pfr/core.hpp>
#include <cassert>
#include <string>
#include <vector>
@@ -15,7 +16,14 @@ struct Sample {
};
int main() {
#if BOOST_PFR_USE_CPP17 || BOOST_PFR_USE_CPP26
static_assert(boost::pfr::index_of(&Sample::x) == 0);
static_assert(boost::pfr::index_of(&Sample::y) == 1);
static_assert(boost::pfr::index_of(&Sample::z) == 2);
#else
assert(boost::pfr::index_of(&Sample::x) == 0);
= 0
assert(boost::pfr::index_of(&Sample::y) == 1);
assert(boost::pfr::index_of(&Sample::z) == 2);
#endif
}