forked from boostorg/range
trac_8693 const cast warn
This commit is contained in:
@ -15,6 +15,7 @@
|
|||||||
#include <boost/range/difference_type.hpp>
|
#include <boost/range/difference_type.hpp>
|
||||||
#include <boost/range/begin.hpp>
|
#include <boost/range/begin.hpp>
|
||||||
#include <boost/range/end.hpp>
|
#include <boost/range/end.hpp>
|
||||||
|
#include <boost/range/detail/implementation_help.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
@ -27,8 +28,8 @@ inline Container& push_back( Container& on, const Range& from )
|
|||||||
{
|
{
|
||||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Container> ));
|
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Container> ));
|
||||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const Range> ));
|
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const Range> ));
|
||||||
BOOST_ASSERT( (void*)&on != (void*)&from &&
|
BOOST_ASSERT_MSG(!range_detail::is_same_object(on, from),
|
||||||
"cannot copy from a container to itself" );
|
"cannot copy from a container to itself");
|
||||||
on.insert( on.end(), boost::begin(from), boost::end(from) );
|
on.insert( on.end(), boost::begin(from), boost::end(from) );
|
||||||
return on;
|
return on;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <boost/range/difference_type.hpp>
|
#include <boost/range/difference_type.hpp>
|
||||||
#include <boost/range/begin.hpp>
|
#include <boost/range/begin.hpp>
|
||||||
#include <boost/range/end.hpp>
|
#include <boost/range/end.hpp>
|
||||||
|
#include <boost/range/detail/implementation_help.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
@ -27,8 +28,8 @@ inline Container& push_front( Container& on, const Range& from )
|
|||||||
{
|
{
|
||||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Container> ));
|
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Container> ));
|
||||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const Range> ));
|
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const Range> ));
|
||||||
BOOST_ASSERT( (void*)&on != (void*)&from &&
|
BOOST_ASSERT_MSG(!range_detail::is_same_object(on, from),
|
||||||
"cannot copy from a container to itself" );
|
"cannot copy from a container to itself");
|
||||||
on.insert( on.begin(), boost::begin(from), boost::end(from) );
|
on.insert( on.begin(), boost::begin(from), boost::end(from) );
|
||||||
return on;
|
return on;
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,17 @@ namespace boost
|
|||||||
return sz;
|
return sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool is_same_address(const void* l, const void* r)
|
||||||
|
{
|
||||||
|
return l == r;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T1, class T2>
|
||||||
|
inline bool is_same_object(const T1& l, const T2& r)
|
||||||
|
{
|
||||||
|
return range_detail::is_same_address(&l, &r);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace 'range_detail'
|
} // namespace 'range_detail'
|
||||||
|
|
||||||
} // namespace 'boost'
|
} // namespace 'boost'
|
||||||
|
Reference in New Issue
Block a user