// Copyright (C) 2009-2012 Lorenzo Caminiti // Distributed under the Boost Software License, Version 1.0 // (see accompanying file LICENSE_1_0.txt or a copy at // http://www.boost.org/LICENSE_1_0.txt) // Home at http://www.boost.org/libs/utility/identity_type #include #include #include //[template_f_decl #define ARG(type, n) type arg ## n template void f( // Prefix macro with `typename` in templates. ARG(typename BOOST_IDENTITY_TYPE((std::map)), 1) ) { std::cout << arg1[0] << std::endl; } //] //[template_g_decl template void g( std::map arg1 ) { std::cout << arg1[0] << std::endl; } //] int main() { //[template_f_call std::map a; a[0] = 'a'; f(a); // OK... // f(a); // ... but error. //] //[template_g_call g(a); // OK... g(a); // ... and also OK. //] return 0; }