Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <type_traits>
- #include <utility>
- #include <cstdlib>
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wglobal-constructors"
- template< typename F >
- F callee = {};
- template< typename F >
- auto call = [] (auto &&... args) -> decltype(auto) { return std::forward< F >(callee< std::decay_t< F > >)(std::forward< decltype(args) >(args)...); };
- #pragma clang diagnostic pop
- #define PP { std::cout << ++i << ' ' << __PRETTY_FUNCTION__ << std::endl; }
- struct L
- {
- mutable int i = 0;
- void operator () () const & { PP }
- void operator () () & { PP }
- void operator () () const && { PP }
- void operator () () && { PP }
- void operator () () volatile const & { PP }
- void operator () () volatile & { PP }
- void operator () () volatile const && { PP }
- void operator () () volatile && { PP }
- };
- struct M
- {
- mutable int i = 0;
- void operator () () const { PP }
- void operator () () { PP }
- void operator () () volatile const { PP }
- void operator () () volatile { PP }
- };
- int
- main()
- {
- { auto const & c = call< L >; c(); }
- { auto const & c = call< L & >; c(); }
- { auto const & c = call< L && >; c(); }
- { auto const & c = call< L const >; c(); }
- { auto const & c = call< L const & >; c(); }
- { auto const & c = call< L const && >; c(); }
- { auto const & c = call< volatile L const >; c(); }
- { auto const & c = call< volatile L const & >; c(); }
- { auto const & c = call< volatile L const && >; c(); }
- std::cout << std::endl;
- { auto const & c = call< M >; c(); }
- { auto const & c = call< M & >; c(); }
- { auto const & c = call< M && >; c(); }
- { auto const & c = call< M const >; c(); }
- { auto const & c = call< M const & >; c(); }
- { auto const & c = call< M const && >; c(); }
- { auto const & c = call< volatile M const >; c(); }
- { auto const & c = call< volatile M const & >; c(); }
- { auto const & c = call< volatile M const && >; c(); }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment