Mirror reflection library 0.5.13
|
This example shows the usage of the meta-programming utilities and the intrinsic meta-functions for various meta-objects
Copyright 2008-2011 Matus Chochlik. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <mirror/mirror.hpp> #include <iostream> #include "./classes.hpp" MIRROR_NAMESPACE_BEGIN template <typename Specifier> struct count_all : public mp::size< mp::only_if< mp::only_if< mp::flatten< MIRRORED_GLOBAL_SCOPE(), members >, mp::is_a< mp::arg<1>, required_param_of< elaborated_type > > >, std::is_same< elaborated_type< mp::arg<1> >, Specifier > > > { }; MIRROR_NAMESPACE_END int main(void) { using namespace mirror; std::cout << count_all<spec_struct_tag>::value << " structs registered." << std::endl; std::cout << count_all<spec_class_tag>::value << " class(es) registered." << std::endl; // return 0; } /* Example of output: 10 structs registered. 1 class(es) registered. */