diff --git a/include/boost/assert/source_location.hpp b/include/boost/assert/source_location.hpp index dd1cfd7..9ab5c29 100644 --- a/include/boost/assert/source_location.hpp +++ b/include/boost/assert/source_location.hpp @@ -115,6 +115,15 @@ public: # pragma warning( pop ) #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 std::basic_ostream & operator<<( std::basic_ostream & os, source_location const & loc ) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index c869ff9..ffe840e 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -42,3 +42,4 @@ run source_location_test2.cpp ; run source_location_test3.cpp ; run source_location_test4.cpp ; run source_location_test5.cpp ; +run source_location_test6.cpp ; diff --git a/test/source_location_test6.cpp b/test/source_location_test6.cpp new file mode 100644 index 0000000..3153597 --- /dev/null +++ b/test/source_location_test6.cpp @@ -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 +#include + +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(); +}