Support for removed function objects in C++17

std::unary_function and std::binary_function are removed in C++17, and
Visual C++ is the first compiler to do this (when the appropriate macro
is defined). I'm not sure what the long term solution should be, but
hopefully this will work for now.
This commit is contained in:
Daniel James
2016-11-01 16:31:21 +00:00
parent e2d7225f57
commit d0ee8e13bd
4 changed files with 24 additions and 7 deletions

View File

@@ -24,6 +24,8 @@ matrix:
env: BJAM_TOOLSET=clang-std03
- compiler: clang
env: BJAM_TOOLSET=clang-std11
- compiler: clang
env: BJAM_TOOLSET=clang-pretend_no_auto_ptr_etc
before_script:
- |
@@ -31,6 +33,7 @@ before_script:
echo "using gcc : std11 : g++-4.8 -Werror --std=c++11 ;" >> ~/user-config.jam
echo "using clang : std03 : clang++ -Werror --std=c++03 ;" >> ~/user-config.jam
echo "using clang : std11 : clang++ -Werror --std=c++11 ;" >> ~/user-config.jam
echo "using clang : pretend_no_auto_ptr_etc : clang++ -Werror --std=c++11 -D_HAS_AUTO_PTR_ETC=0 ;" >> ~/user-config.jam
- cat ~/user-config.jam
- touch Jamroot.jam

View File

@@ -254,7 +254,7 @@ namespace boost
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
template <class T> struct hash
: std::unary_function<T, std::size_t>
: boost::hash_detail::hash_base<T>
{
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
std::size_t operator()(T const& val) const
@@ -271,7 +271,7 @@ namespace boost
#if BOOST_WORKAROUND(__DMC__, <= 0x848)
template <class T, unsigned int n> struct hash<T[n]>
: std::unary_function<T[n], std::size_t>
: boost::hash_detail::hash_base<T[n]>
{
std::size_t operator()(const T* val) const
{
@@ -296,7 +296,7 @@ namespace boost
{
template <class T>
struct inner
: std::unary_function<T, std::size_t>
: boost::hash_detail::hash_base<T>
{
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
std::size_t operator()(T const& val) const

View File

@@ -62,6 +62,18 @@ namespace boost
{
namespace hash_detail
{
#if defined(_HAS_AUTO_PTR_ETC) && !_HAS_AUTO_PTR_ETC
template <typename T>
struct hash_base
{
typedef T argument_type;
typedef std::size_t result_type;
};
#else
template <typename T>
struct hash_base : std::unary_function<T, std::size_t> {};
#endif
struct enable_hash_value { typedef std::size_t type; };
template <typename T> struct basic_numbers {};
@@ -419,7 +431,7 @@ namespace boost
#define BOOST_HASH_SPECIALIZE(type) \
template <> struct hash<type> \
: public std::unary_function<type, std::size_t> \
: public boost::hash_detail::hash_base<type> \
{ \
std::size_t operator()(type v) const \
{ \
@@ -429,7 +441,7 @@ namespace boost
#define BOOST_HASH_SPECIALIZE_REF(type) \
template <> struct hash<type> \
: public std::unary_function<type, std::size_t> \
: public boost::hash_detail::hash_base<type> \
{ \
std::size_t operator()(type const& v) const \
{ \
@@ -483,7 +495,7 @@ namespace boost
template <class T>
struct hash<T*>
: public std::unary_function<T*, std::size_t>
: public boost::hash_detail::hash_base<T*>
{
std::size_t operator()(T* v) const
{
@@ -516,7 +528,7 @@ namespace boost
{
template <class T>
struct inner
: public std::unary_function<T, std::size_t>
: public boost::hash_detail::hash_base<T>
{
std::size_t operator()(T val) const
{

View File

@@ -10,7 +10,9 @@
template <class T>
void compile_time_tests(T*)
{
#if !defined(_HAS_AUTO_PTR_ETC) || _HAS_AUTO_PTR_ETC
BOOST_STATIC_ASSERT((boost::is_base_and_derived<
std::unary_function<T, std::size_t>, BOOST_HASH_TEST_NAMESPACE::hash<T> >::value));
#endif
}