-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved boost::swap into a detail namespace to avoid it being found via…
… ADL. This resolves infinite recursion when boost::swap is called on types that are defined in namespace boost. The swap_impl implementation and noexcept specification is using an unqualified call to swap, so if the argument types are defined in namespace boost then our boost::swap function may be found and selected to resolve the call. Fixes #148.
- Loading branch information
Showing
3 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2023 Andrey Semashev | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. | ||
// (See accompanying file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
// Tests that boost::swap with types in namespace boost is not | ||
// found via ADL and does not introduce infinite recursion. | ||
|
||
#include <boost/core/swap.hpp> | ||
|
||
namespace boost { | ||
|
||
struct boost_type {}; | ||
|
||
} | ||
|
||
namespace test_ns { | ||
|
||
template<class T> class X | ||
{ | ||
X( X const& ); | ||
|
||
public: | ||
|
||
X() {} | ||
}; | ||
|
||
template< typename T1, typename T2 > | ||
inline void swap(T1&, T2&) | ||
{ | ||
} | ||
|
||
} | ||
|
||
int main() | ||
{ | ||
test_ns::X< boost::boost_type > x; | ||
return noexcept( boost::swap( x, x ) ); | ||
} |