forked from boostorg/config
Merge pull request #42 from Flast/bugfix/cxx14/clang34-constexpr
Define BOOST_NO_CXX14_CONSTEXPR unless clang > 3.4.
This commit is contained in:
@ -225,7 +225,16 @@
|
|||||||
# define BOOST_NO_CXX14_GENERIC_LAMBDAS
|
# define BOOST_NO_CXX14_GENERIC_LAMBDAS
|
||||||
#endif
|
#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
|
# define BOOST_NO_CXX14_CONSTEXPR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -14,7 +14,15 @@
|
|||||||
namespace boost_no_cxx14_constexpr
|
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;
|
--value;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user