Conversation
|
まだ大量に抜けがありそう |
|
これの取り消しに対応しないといけない |
| template <typename E> | ||
| requires std::is_enum_v<E> | ||
| constexpr std::string_view to_string(E value) { | ||
| template for (constexpr auto e : std::meta::enumerators_of(^^E)) { // 型から列挙子のリストを取得 |
There was a problem hiding this comment.
template for (constexpr auto e : ~)構文でstd::vector<std::meta::info>を走査するときはstd::define_static_arrayで配列型(std::meta::info[N])に変換しておく必要があります。
template for (constexpr auto e : std::define_static_array(std::meta::enumerators_of(^^E))) {
// ...|
|
||
| // メンバのアノテーションを取得 | ||
| template for (constexpr auto m : | ||
| std::meta::nonstatic_data_members_of(^^Point, |
There was a problem hiding this comment.
要std::define_static_array
template for (constexpr auto m :
std::define_static_array(
std::meta::nonstatic_data_members_of(
^^Point, std::meta::access_context::unchecked())) {| template <typename E> | ||
| requires std::is_enum_v<E> | ||
| constexpr std::string_view enum_to_string(E value) { | ||
| template for (constexpr auto e : std::meta::enumerators_of(^^E)) { |
lang/cpp26/reflection.md
Outdated
| constexpr std::string_view enum_to_string(E value) { | ||
| template for (constexpr auto e : std::meta::enumerators_of(^^E)) { | ||
| if (value == [:e:]) { | ||
| return std::meta::define_static_string(std::meta::identifier_of(e)); |
There was a problem hiding this comment.
std::meta::identifier_ofはstd::string_viewを返すためstd::meta::define_static_stringは不要(冗長)です。(厳密にはstd名前空間所属ですね)
| int main() { | ||
| Point p{10, 20, "origin"}; | ||
|
|
||
| template for (constexpr auto m : |
| template <typename E> | ||
| requires std::is_enum_v<E> | ||
| constexpr std::string_view to_string(E value) { | ||
| template for (constexpr auto e : std::meta::enumerators_of(^^E)) { |
| void process(int id, double value, const char* name) {} | ||
|
|
||
| int main() { | ||
| template for (constexpr auto p : std::meta::parameters_of(^^process)) { |
| constexpr auto members = std::meta::members_of( | ||
| ^^S, std::meta::access_context::unchecked()); |
There was a problem hiding this comment.
std::vector<std::meta::info> をconstexpr変数で持つことはできません。
std::define_static_array で静的ストレージに配置するか、
定数式内の一時オブジェクトとして使うか、
constexprの文脈でconstexprでない変数として使うべきです。
constexpr auto members = std::define_static_array(members_of(^^S, std::meta::access_context::unchecked()));constexpr auto ctx = std::meta::access_context::unchecked();
constexpr auto member0 = members_of(^^S, ctx)[0];
constexpr auto member1 = members_of(^^S, ctx)[1];#include <cassert>
consteval {
auto members = members_of(^^S, std::meta::access_context::unchecked());
assert(type_of(parameters_of(members[0])[0]) == ^^int);
assert(type_of(parameters_of(members[1])[0]) == ^^double);
}| constexpr auto members = std::meta::nonstatic_data_members_of( | ||
| ^^S, std::meta::access_context::unchecked()); |
There was a problem hiding this comment.
std::vector<std::meta::info> をconstexpr変数で持つことはできません。
|
@yohhoy @Raclamusi |
6d21c35 to
32cd88c
Compare
Co-authored-by: Raclamusi <61970673+Raclamusi@users.noreply.github.com>
cfe6abb to
741186c
Compare
…る必要がある Co-authored-by: Raclamusi <61970673+Raclamusi@users.noreply.github.com>
…必要がある Co-authored-by: Raclamusi <61970673+Raclamusi@users.noreply.github.com>
Co-authored-by: Raclamusi <61970673+Raclamusi@users.noreply.github.com>
Co-authored-by: Raclamusi <61970673+Raclamusi@users.noreply.github.com>
Co-authored-by: Raclamusi <61970673+Raclamusi@users.noreply.github.com>
Co-authored-by: Raclamusi <61970673+Raclamusi@users.noreply.github.com>
Co-authored-by: Raclamusi <61970673+Raclamusi@users.noreply.github.com>
Co-authored-by: Raclamusi <61970673+Raclamusi@users.noreply.github.com>
|
一旦、コミットを整理しつつ @Raclamusi さんの変更を取り込みました |
|
ページ数としては、一旦過不足がなくなったはず。 |
一通り軽くチェックしたくらいなので、作業漏れチェックなどしてからマージします。