Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <functional>
- #include <cstdlib>
- struct test
- //: boost::static_visitor<>
- {
- using result_type = void;
- template< typename... P >
- result_type apply_filter(P &&... _p) const
- {
- return operator () (filter(_p)...);
- }
- template< typename... T >
- result_type operator () (std::string const & _s, T &&... _tail) const
- {
- std::cout << _s << std::endl;
- return operator () (std::forward< T >(_tail)...);
- }
- template< typename... T >
- result_type operator () (double const & _x, T &&... _tail) const
- {
- std::cout << _x << std::endl;
- return operator () (std::forward< T >(_tail)...);
- }
- private :
- result_type operator () () const { return; }
- std::string filter(std::string const & _s) const
- {
- return "\"" + _s + "\"";
- }
- double filter(double const & _x) const
- {
- return _x + 1.0;
- }
- };
- int main()
- {
- test const test_;
- test_.apply_filter(1.0, "x", 0.0, "y");
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment