From 4fc826321d3df9ba818cd6ecefcec1ba90dd4567 Mon Sep 17 00:00:00 2001 From: liuzicheng1987 Date: Wed, 4 Oct 2023 20:11:29 +0200 Subject: [PATCH] Use names instead of types in the example --- docs/variants_and_tagged_unions.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/variants_and_tagged_unions.md b/docs/variants_and_tagged_unions.md index bd04088a..5e86a27d 100644 --- a/docs/variants_and_tagged_unions.md +++ b/docs/variants_and_tagged_unions.md @@ -136,12 +136,12 @@ const Shapes my_shape = rfl::make_field<"rectangle">(Rectangle{.height = 10, .width = 5}); const auto handle_shapes = [](const auto& field) { - using Type = typename std::decay_t(decltype(field))::Type; - if constexpr (std::is_same()) { + using Name = typename std::decay_t(decltype(field))::Name; + if constexpr (std::is_same>()) { std::cout << is circle, radius: << field.value().radius() << std::endl; - } else if constexpr (std::is_same()) { + } else if constexpr (std::is_same>()) { std::cout << is rectangle, width: << field.value().width() << ", height: " << field.value().height() << std::endl; - } else if constexpr (std::is_same()) { + } else if constexpr (std::is_same>()) { std::cout << is square, width: << field.value().width() << std::endl; } else { // reflect-cpp also provides this very useful helper that ensures