Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / config / test / boost_no_constexpr.ipp
1 //  (C) Copyright Beman Dawes 2008
2
3 //  Use, modification and distribution are subject to the
4 //  Boost Software License, Version 1.0. (See accompanying file
5 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6
7 //  See http://www.boost.org/libs/config for more information.
8
9 //  MACRO:         BOOST_NO_CXX11_CONSTEXPR 
10 //  TITLE:         C++0x constexpr unavailable
11 //  DESCRIPTION:   The compiler does not support C++0x constexpr
12
13 namespace boost_no_cxx11_constexpr {
14
15 void quiet_warning(int){}
16
17 constexpr int square(int x) { return x * x; }  // from N2235
18
19 // from 5.19:
20 constexpr const int* addr(const int& ir) { return &ir; }
21 static const int x = 5;
22 constexpr const int* xp = addr(x);
23
24 struct A 
25 {
26    constexpr A(int i) : val(i) { }
27    constexpr operator int()const { return val; }
28    constexpr operator long()const { return 43; }
29 private:
30    int val;
31 };
32
33 template<int> struct X { };
34
35 constexpr const A a = 42;
36
37 X<a> xx; // OK: unique conversion to int
38
39 int test()
40 {
41   int i = square(5);
42   quiet_warning(i);
43   return 0;
44 }
45
46 }