forked from boostorg/conversion
make boost::implicit_cast constexpr (fixes #25)
This commit is contained in:
@@ -6,6 +6,11 @@
|
|||||||
#ifndef BOOST_IMPLICIT_CAST_DWA200356_HPP
|
#ifndef BOOST_IMPLICIT_CAST_DWA200356_HPP
|
||||||
#define BOOST_IMPLICIT_CAST_DWA200356_HPP
|
#define BOOST_IMPLICIT_CAST_DWA200356_HPP
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
#ifdef BOOST_HAS_PRAGMA_ONCE
|
||||||
|
# pragma once
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
@@ -23,7 +28,7 @@ template<class T> struct icast_identity
|
|||||||
// The use of identity creates a non-deduced form, so that the
|
// The use of identity creates a non-deduced form, so that the
|
||||||
// explicit template argument must be supplied
|
// explicit template argument must be supplied
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T implicit_cast (typename boost::detail::icast_identity<T>::type x) {
|
BOOST_CONSTEXPR inline T implicit_cast (typename boost::detail::icast_identity<T>::type x) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,5 +34,9 @@ int main()
|
|||||||
(void)f;
|
(void)f;
|
||||||
(void)z;
|
(void)z;
|
||||||
|
|
||||||
|
|
||||||
|
BOOST_CONSTEXPR long value = boost::implicit_cast<long>(42);
|
||||||
|
BOOST_TEST(value == 42L);
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user