Hi Peter,
i implemented signature_of similar to the function_traits. This is more flexible, but requires C++20.
#include <iostream>
#include <cstdlib>
#include <utility>
#include
int foo(bool, float&, const uint64_t, const double&);
template <typename Type> void show_type() noexcept
{
std::cout << typeid(Type).name() << std::endl;
}
template <typename Tuple> void show_tuple_types() noexcept
{
auto show_elems = [](const std::index_sequence&) noexcept
{
(show_type>(), ...);
};
show_elems(std::make_index_sequence{});
}
int main(const int argc, const char** args)
{
using sig_foo = boost::signature_of<foo>; // or &foo
std::cout << "foo\n";
std::cout << "result:\t\t\t" << typeid(sig_foo::result_type).name() << std::endl;
std::cout << "tuple<arguments>:\t" << typeid(sig_foo::argument_type).name() << std::endl;
std::cout << "argument size:\t\t" << boost::argument_size_v<foo> << std::endl;
std::cout << "argument types are:\n";
show_tuple_types<typename sig_foo::argument_type>();
using sig_baz = boost::signature_of<&bar::baz>;
std::cout << "\nbaz\n";
std::cout << "result:\t\t\t" << typeid(sig_baz::result_type).name() << std::endl;
std::cout << "tuple<arguments>:\t" << typeid(sig_baz::argument_type).name() << std::endl;
std::cout << "argument size:\t\t" << boost::argument_size_v<&bar::baz> << std::endl;
std::cout << "argument types are:\n";
show_tuple_types<typename sig_baz::argument_type>();
return EXIT_SUCCESS;
}
(Hint: typeid ignore references)
regards
Gero
Am 12.09.20 um 17:35 schrieb Peter Dimov via Boost:
Gero Peterhoff wrote:
Hello Developers,
I would like to retrofit some type-traits in boost, but I have read https://pdimov.github.io/articles/phasing_out_cxx03.html. Now I don't know how to do it best, as the boost-type-traits may be removed.
Boost.TypeTraits is not made obsolete by C++11, so it won't be removed. It contains both non-standard traits and traits that have been added in a later standard (17, 20). F.ex.
https://www.boost.org/doc/libs/1_74_0/libs/type_traits/doc/html/boost_typetr...
https://www.boost.org/doc/libs/1_74_0/libs/type_traits/doc/html/boost_typetr...
https://www.boost.org/doc/libs/1_74_0/libs/type_traits/doc/html/boost_typetr...
https://www.boost.org/doc/libs/1_74_0/libs/type_traits/doc/html/boost_typetr...
https://www.boost.org/doc/libs/1_74_0/libs/type_traits/doc/html/boost_typetr...
https://www.boost.org/doc/libs/1_74_0/libs/type_traits/doc/html/boost_typetr...
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost