#include "introspection.hpp" #include "tap.hpp" //----------------------------------------------------------------------------- // simple test struct of scalars struct foo { int a; float b; }; //----------------------------------------------------------------------------- // define introspection data namespace cruft { template <> struct type { typedef std::tuple< field, field > fields; }; template <> const std::string field::name = "a"; template <> const std::string field::name = "b"; } //----------------------------------------------------------------------------- int main () { cruft::TAP::logger tap; // Ensure tuples are mapped to themselves with type_tuple::type { using src_t = std::tuple; using dst_t = typename cruft::type_tuple::type; tap.expect (std::is_same::value, "static identity type_tuple"); } // Check member extraction from a simple POD structure. { foo d_foo { 7, 42.0 }; auto f_tuple = cruft::as_tuple (d_foo); tap.expect (cruft::equal (d_foo.a, std::get<0> (f_tuple)) && cruft::equal (d_foo.b, std::get<1> (f_tuple)), "dynamic member access after conversion to tuple"); } return tap.status (); }