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