Define BOOST_NO_CXX14_CONSTEXPR unless clang > 3.4.

Signed-off-by: Kohei Takahashi <flast@flast.jp>
This commit is contained in:
Kohei Takahashi
2014-10-19 21:25:49 +09:00
parent ec1f5273be
commit 78e67031e3
2 changed files with 19 additions and 2 deletions

View File

@ -225,7 +225,16 @@
# define BOOST_NO_CXX14_GENERIC_LAMBDAS
#endif
#if !(__has_feature(cxx_relaxed_constexpr) || __has_extension(cxx_relaxed_constexpr))
// clang < 3.5 has a defect with dependent type, like following.
//
// template <class T>
// constexpr typename enable_if<pred<T> >::type foo(T &)
// { } // error: no return statement in constexpr function
//
// This issue also affects C++11 mode, but C++11 constexpr requires return stmt.
// Therefore we don't care such case.
#if (__clang_major__ == 3 && __clang_minor__ < 5) \
|| !(__has_feature(cxx_relaxed_constexpr) || __has_extension(cxx_relaxed_constexpr))
# define BOOST_NO_CXX14_CONSTEXPR
#endif

View File

@ -14,7 +14,15 @@
namespace boost_no_cxx14_constexpr
{
constexpr void decrement(int &value)
namespace detail
{
template <class> struct void_ { typedef void type; };
}
// Test relaxed constexpr with dependent type; for more details, see comment of
// BOOST_CXX14_CONSTEXPR definition in boost/config/compiler/clang.hpp .
template <class T>
constexpr typename detail::void_<T>::type decrement(T &value)
{
--value;
}