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/config 7 8// MACRO: BOOST_NO_CXX11_LOCAL_CLASS_TEMPLATE_PARAMETERS 9// TITLE: local classes as template parameters 10// DESCRIPTION: Local classes cannot be passed as template parameters. 11 12// NOTE: Local classes cannot be passed as template parameters in C++03 (even 13// if some C++03 compilers, like MSVC and older GCC, allow it). Local classes 14// can instead be passed as template parameters in C++11 (see also N2657, note 15// that this macro does not check if unnamed types can also be passed as 16// template parameters but it is intentionally limited to local named classes 17// because some non C++11 compilers might only support local named classes as 18// template parameters which is still very useful to program local functors). 19namespace boost_no_cxx11_local_class_template_parameters { 20 21template<typename T> struct a { void use() {} }; 22template<typename T> void f(T) {} 23 24int test() { 25 class local_class {} local_obj; 26 a<local_class> a1; 27 a1.use(); // Avoid unused variable warning. 28 f(local_obj); 29 return 0; 30} 31 32} // namespace 33 34