// (C) Copyright Tobias Schwinger // // Use modification and distribution are subject to the boost Software License, // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt). //------------------------------------------------------------------------------ // See macro_type_arugment.hpp in this directory for details. #include #include #include #include #include #include "macro_type_args.hpp" #define TYPE_NAME(parenthesized_type) \ typeid(BOOST_EXAMPLE_MACRO_TYPE_ARGUMENT(parenthesized_type)).name() namespace example { namespace mpl = boost::mpl; template struct mpl_seq_to_string_impl { static std::string get(std::string const & prev) { typedef typename mpl::next::type next_pos; typedef typename mpl::deref::type type; return mpl_seq_to_string_impl::get( prev + (prev.empty()? '\0' : ',') + typeid(type).name() ); } }; template struct mpl_seq_to_string_impl { static std::string get(std::string const & prev) { return prev; } }; template std::string mpl_seq_to_string() { typedef typename mpl::begin::type begin; typedef typename mpl::end::type end; return mpl_seq_to_string_impl::get(""); } } #define TYPE_NAMES(parenthesized_types) \ ::example::mpl_seq_to_string< \ BOOST_EXAMPLE_MACRO_TYPE_LIST_ARGUMENT(parenthesized_types) >() int main() { std::cout << TYPE_NAME((int)) << std::endl; std::cout << TYPE_NAMES((int,char)) << std::endl; std::cout << TYPE_NAMES((int,char,long)) << std::endl; }