]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
2 | // (C) Copyright Beman Dawes 2008 | |
3 | ||
4 | // Use, modification and distribution are subject to the | |
5 | // Boost Software License, Version 1.0. (See accompanying file | |
6 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
7 | ||
8 | // See http://www.boost.org/libs/config for more information. | |
9 | ||
10 | // MACRO: BOOST_NO_CXX11_DECLTYPE | |
11 | // TITLE: C++0x decltype unavailable | |
12 | // DESCRIPTION: The compiler does not support C++0x decltype | |
13 | ||
14 | namespace boost_no_cxx11_decltype { | |
15 | ||
16 | void quiet_warning(int){} | |
17 | ||
18 | struct test_class | |
19 | { | |
20 | test_class() {} | |
21 | }; | |
22 | ||
23 | test_class get_test_class() | |
24 | { | |
25 | return test_class(); | |
26 | } | |
27 | ||
28 | template<typename F> | |
29 | void baz(F f) | |
30 | { | |
31 | // | |
32 | // Strangely VC-10 deduces the return type of F | |
33 | // to be "test_class&". Remove the constructor | |
34 | // from test_class and then decltype does work OK!! | |
35 | // | |
36 | typedef decltype(f()) res; | |
37 | res r; | |
38 | } | |
39 | ||
40 | int test() | |
41 | { | |
42 | int i; | |
43 | decltype(i) j(0); | |
44 | quiet_warning(j); | |
45 | decltype(get_test_class()) k; | |
46 | #ifndef _MSC_VER | |
47 | // Although the VC++ decltype is buggy, we none the less enable support, | |
48 | // so don't test the bugs for now! | |
49 | baz(get_test_class); | |
50 | #endif | |
51 | return 0; | |
52 | } | |
53 | ||
54 | } |