2009-02-25 18:04:27 +00:00
|
|
|
// (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.
|
|
|
|
|
|
2012-07-10 13:57:24 +00:00
|
|
|
// MACRO: BOOST_NO_CXX11_CONSTEXPR
|
2009-02-25 18:04:27 +00:00
|
|
|
// TITLE: C++0x constexpr unavailable
|
|
|
|
|
// DESCRIPTION: The compiler does not support C++0x constexpr
|
|
|
|
|
|
2012-07-10 19:10:08 +00:00
|
|
|
namespace boost_no_cxx11_constexpr {
|
2009-02-25 18:04:27 +00:00
|
|
|
|
2011-10-31 11:21:10 +00:00
|
|
|
void quiet_warning(int){}
|
|
|
|
|
|
2009-02-25 18:04:27 +00:00
|
|
|
constexpr int square(int x) { return x * x; } // from N2235
|
|
|
|
|
|
2011-03-15 13:17:46 +00:00
|
|
|
// 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;
|
|
|
|
|
|
2011-03-30 18:24:18 +00:00
|
|
|
X<a> xx; // OK: unique conversion to int
|
2011-03-15 13:17:46 +00:00
|
|
|
|
2009-02-25 18:04:27 +00:00
|
|
|
int test()
|
|
|
|
|
{
|
|
|
|
|
int i = square(5);
|
2011-10-31 11:21:10 +00:00
|
|
|
quiet_warning(i);
|
2009-02-25 18:04:27 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|