Boost logo

Boost :

From: Alexander Grund (alexander.grund_at_[hidden])
Date: 2020-09-14 09:04:11


I'm not a big fan of the NTTP used especially as e.g. for overloaded
operator() the result is ambigious. What was the reason for choosing it?

Besides that as Peter said the tuple/MPL list of arguments is a good
idea. Another good idea is improved handling of member functions. E.g.
in C++11 and up you don't only have const and noexcept but also rvalue
and lvalue specifiers. So that could be added too

Regards,
Alex

Am 12.09.20 um 20:33 schrieb Gero Peterhoff via Boost:
> 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 <boost/type_traits/signature_of.hpp>
>
> 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 = []<std::size_t... Idx>(const std::index_sequence<Idx...>&) noexcept
> {
> (show_type<std::tuple_element_t<Idx, Tuple>>(), ...);
> };
>
> show_elems(std::make_index_sequence<std::tuple_size_v<Tuple>>{});
> }
>
> 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




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk