Merge pull request #252 from boostorg/issue246

Add test case for issue #246
This commit is contained in:
jzmaddock
2018-11-08 08:47:59 +00:00
committed by GitHub
2 changed files with 13 additions and 8 deletions

View File

@ -232,7 +232,6 @@
// C++0x features in 4.6.n and later
//
#if (BOOST_GCC_VERSION < 40600) || !defined(BOOST_GCC_CXX11)
#define BOOST_NO_CXX11_CONSTEXPR
#define BOOST_NO_CXX11_DEFAULTED_MOVES
#define BOOST_NO_CXX11_NOEXCEPT
#define BOOST_NO_CXX11_NULLPTR
@ -243,6 +242,9 @@
// C++0x features in 4.7.n and later
//
#if (BOOST_GCC_VERSION < 40700) || !defined(BOOST_GCC_CXX11)
// Note that while constexpr is partly supported in gcc-4.6 it's a
// pre-std version with several bugs:
# define BOOST_NO_CXX11_CONSTEXPR
# define BOOST_NO_CXX11_FINAL
# define BOOST_NO_CXX11_TEMPLATE_ALIASES
# define BOOST_NO_CXX11_USER_DEFINED_LITERALS

View File

@ -32,13 +32,7 @@ private:
template<int> struct X { };
#if __cplusplus < 201400L
// Some C++14 compilers reject this (clang), some C++11 compilers reject "constexpr const" (GCC-4.6)
constexpr A a = 42;
#else
constexpr const A a = 42;
#endif
X<a> xx; // OK: unique conversion to int
@ -68,9 +62,18 @@ struct F : virtual E
};
constexpr F& f(F& out) { return out; }
namespace whatever{};
constexpr int factorial(int i)
{
typedef int value_type;
using namespace whatever;
return i <= 1 ? 1 : i * factorial(value_type(i-1));
}
int test()
{
int i = square(5);
constexpr int i = square(5) + factorial(10);
quiet_warning(i);
switch (i)