Files
reflect-cpp/tests/flexbuffers/test_variant.cpp
T
2023-12-16 19:03:56 +08:00

38 lines
727 B
C++

#include "test_variant.hpp"
#include <cassert>
#include <iostream>
#include <rfl.hpp>
#include <rfl/flexbuf.hpp>
#include <source_location>
#include <string>
#include <vector>
#include "write_and_read.hpp"
namespace test_variant {
struct Circle {
rfl::Field<"radius", double> radius;
};
struct Rectangle {
rfl::Field<"height", double> height;
rfl::Field<"width", double> width;
};
struct Square {
rfl::Field<"width", double> width;
};
void test() {
std::cout << std::source_location::current().function_name() << std::endl;
using Shapes = std::variant<Circle, Rectangle, std::unique_ptr<Square>>;
const Shapes r = Rectangle{.height = 10, .width = 5};
write_and_read(r);
}
} // namespace test_variant