1 | |
2 | // Copyright (C) 2009-2012 Lorenzo Caminiti |
3 | // Distributed under the Boost Software License, Version 1.0 |
4 | // (see accompanying file LICENSE_1_0.txt or a copy at |
5 | // http://www.boost.org/LICENSE_1_0.txt) |
6 | // Home at http://www.boost.org/libs/local_function |
7 | |
8 | #include <boost/local_function.hpp> |
9 | #include <boost/utility/identity_type.hpp> |
10 | #include <boost/typeof/std/string.hpp> // Type-of registrations |
11 | #include <boost/typeof/std/map.hpp> // needed for `NAME` macro. |
12 | #include <boost/config.hpp> |
13 | #include <map> |
14 | #include <string> |
15 | |
16 | std::string cat(const std::string& x, const std::string& y) { return x + y; } |
17 | |
18 | template<typename V, typename K> |
19 | struct key_sizeof { |
20 | static int const value; |
21 | }; |
22 | |
23 | template<typename V, typename K> |
24 | int const key_sizeof<V, K>::value = sizeof(K); |
25 | |
26 | typedef int sign_t; |
27 | |
28 | int main(void) { |
29 | void BOOST_LOCAL_FUNCTION( |
30 | (BOOST_IDENTITY_TYPE((const std::map<std::string, size_t>&)) m) |
31 | (BOOST_IDENTITY_TYPE((::sign_t)) sign) |
32 | (const size_t& factor) |
33 | (default (key_sizeof<std::string, size_t>::value)) |
34 | (const std::string& separator)(default cat(":" , " " )) |
35 | ) { |
36 | // Do something... |
37 | } BOOST_LOCAL_FUNCTION_NAME(f) |
38 | |
39 | std::map<std::string, size_t> m; |
40 | ::sign_t sign = -1; |
41 | f(m, sign); |
42 | return 0; |
43 | } |
44 | |
45 | |