mirror of
https://github.com/boostorg/core.git
synced 2025-11-28 21:30:09 +01:00
Move fclose_deleter and null_deleter to their own namespaces to block ADL.
This prevents bringing namespace boost into ADL when the deleters are used in template parameters, e.g. in std::unique_ptr.
This commit is contained in:
@@ -26,6 +26,9 @@
|
||||
|
||||
namespace boost {
|
||||
|
||||
// Block unintended ADL
|
||||
namespace fclose_deleter_ns {
|
||||
|
||||
//! A function object that closes a file
|
||||
struct fclose_deleter
|
||||
{
|
||||
@@ -41,6 +44,10 @@ struct fclose_deleter
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace fclose_deleter_ns
|
||||
|
||||
using fclose_deleter_ns::fclose_deleter;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_CORE_FCLOSE_DELETER_HPP
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
|
||||
namespace boost {
|
||||
|
||||
// Block unintended ADL
|
||||
namespace null_deleter_ns {
|
||||
|
||||
//! A function object that does nothing and can be used as an empty deleter for \c shared_ptr
|
||||
struct null_deleter
|
||||
{
|
||||
@@ -39,6 +42,10 @@ struct null_deleter
|
||||
void operator() (T*) const BOOST_NOEXCEPT {}
|
||||
};
|
||||
|
||||
} // namespace null_deleter_ns
|
||||
|
||||
using null_deleter_ns::null_deleter;
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_CORE_NULL_DELETER_HPP
|
||||
|
||||
Reference in New Issue
Block a user