From 259e917eaf4929b0137717011db9bdd40fc990ab Mon Sep 17 00:00:00 2001 From: Neil Groves Date: Wed, 26 Feb 2014 22:02:27 +0000 Subject: [PATCH] trac_8693 const cast warn --- include/boost/range/algorithm_ext/push_back.hpp | 5 +++-- include/boost/range/algorithm_ext/push_front.hpp | 5 +++-- include/boost/range/detail/implementation_help.hpp | 11 +++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/boost/range/algorithm_ext/push_back.hpp b/include/boost/range/algorithm_ext/push_back.hpp index 51a7a7b..6fb9b9b 100755 --- a/include/boost/range/algorithm_ext/push_back.hpp +++ b/include/boost/range/algorithm_ext/push_back.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include namespace boost @@ -27,8 +28,8 @@ inline Container& push_back( Container& on, const Range& from ) { BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_ASSERT( (void*)&on != (void*)&from && - "cannot copy from a container to itself" ); + BOOST_ASSERT_MSG(!range_detail::is_same_object(on, from), + "cannot copy from a container to itself"); on.insert( on.end(), boost::begin(from), boost::end(from) ); return on; } diff --git a/include/boost/range/algorithm_ext/push_front.hpp b/include/boost/range/algorithm_ext/push_front.hpp index 470d793..e893098 100755 --- a/include/boost/range/algorithm_ext/push_front.hpp +++ b/include/boost/range/algorithm_ext/push_front.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include namespace boost @@ -27,8 +28,8 @@ inline Container& push_front( Container& on, const Range& from ) { BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_ASSERT( (void*)&on != (void*)&from && - "cannot copy from a container to itself" ); + BOOST_ASSERT_MSG(!range_detail::is_same_object(on, from), + "cannot copy from a container to itself"); on.insert( on.begin(), boost::begin(from), boost::end(from) ); return on; } diff --git a/include/boost/range/detail/implementation_help.hpp b/include/boost/range/detail/implementation_help.hpp index ca12fa4..1560587 100755 --- a/include/boost/range/detail/implementation_help.hpp +++ b/include/boost/range/detail/implementation_help.hpp @@ -95,6 +95,17 @@ namespace boost return sz; } + inline bool is_same_address(const void* l, const void* r) + { + return l == r; + } + + template + inline bool is_same_object(const T1& l, const T2& r) + { + return range_detail::is_same_address(&l, &r); + } + } // namespace 'range_detail' } // namespace 'boost'