/*============================================================================= Copyright (c) 2006 Joel de Guzman Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #include "overload.hpp" #include #include #include int foo1(char) { return 123; } double foo2(int, char) { return 123.456; } char foo3(std::string) { return 'x'; } void foo4(std::string s1, std::string s2, std::string s3) { std::cout << s1 << s2 << s3 << std::endl; } int main() { boost::overload< int(char) , double(int, char) , char(std::string) , void(std::string, std::string, std::string) > f; f.set<0>(&foo1); f.set<1>(&foo2); f.set<2>(&foo3); f.set<3>(&foo4); int i = f('x'); double d = f(123, 'x'); char c = f("hello"); f("Hello", ", World", ", I'm Joel"); BOOST_ASSERT(i == 123); BOOST_ASSERT(d > 123.455 && d < 123.457); BOOST_ASSERT(c == 'x'); return boost::report_errors(); }