forked from boostorg/assert
Add operator==, operator!= to source_location
This commit is contained in:
@ -115,6 +115,15 @@ public:
|
|||||||
# pragma warning( pop )
|
# pragma warning( pop )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
inline friend bool operator==( source_location const& s1, source_location const& s2 ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return std::strcmp( s1.file_, s2.file_ ) == 0 && std::strcmp( s1.function_, s2.function_ ) == 0 && s1.line_ == s2.line_ && s1.column_ == s2.column_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline friend bool operator!=( source_location const& s1, source_location const& s2 ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return !( s1 == s2 );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class E, class T> std::basic_ostream<E, T> & operator<<( std::basic_ostream<E, T> & os, source_location const & loc )
|
template<class E, class T> std::basic_ostream<E, T> & operator<<( std::basic_ostream<E, T> & os, source_location const & loc )
|
||||||
|
@ -42,3 +42,4 @@ run source_location_test2.cpp ;
|
|||||||
run source_location_test3.cpp ;
|
run source_location_test3.cpp ;
|
||||||
run source_location_test4.cpp ;
|
run source_location_test4.cpp ;
|
||||||
run source_location_test5.cpp ;
|
run source_location_test5.cpp ;
|
||||||
|
run source_location_test6.cpp ;
|
||||||
|
23
test/source_location_test6.cpp
Normal file
23
test/source_location_test6.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright 2019 Peter Dimov
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/assert/source_location.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
boost::source_location loc, loc2;
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( loc, loc2 );
|
||||||
|
|
||||||
|
boost::source_location loc3 = BOOST_CURRENT_LOCATION;
|
||||||
|
boost::source_location loc4( loc3 );
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( loc3, loc4 );
|
||||||
|
BOOST_TEST_NE( loc3, loc );
|
||||||
|
}
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
Reference in New Issue
Block a user