diff --git a/include/boost/core/functor.hpp b/include/boost/core/functor.hpp index 441f940..f3ee11b 100644 --- a/include/boost/core/functor.hpp +++ b/include/boost/core/functor.hpp @@ -18,6 +18,9 @@ namespace boost::core { +// Block unintended ADL +namespace functor_ns { + //! A function object that invokes a function specified as its template parameter template< auto Function > struct functor @@ -29,6 +32,10 @@ struct functor } }; +} // namespace functor_ns + +using functor_ns::functor; + } // namespace boost::core #endif // BOOST_CORE_FUNCTOR_HPP diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index c88ec4f..d69d3ee 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -195,6 +195,9 @@ compile-fail fclose_deleter_compile_fail_adl.cpp : windows:_CRT_SECURE_NO_WARNINGS windows:_CRT_SECURE_NO_DEPRECATE $(warnings-as-errors-off) ; run functor_test.cpp ; +compile-fail functor_compile_fail_adl.cpp + : $(warnings-as-errors-off) ; + run pointer_traits_pointer_test.cpp ; run pointer_traits_element_type_test.cpp ; diff --git a/test/functor_compile_fail_adl.cpp b/test/functor_compile_fail_adl.cpp new file mode 100644 index 0000000..cc47765 --- /dev/null +++ b/test/functor_compile_fail_adl.cpp @@ -0,0 +1,32 @@ +/* + * Copyright Andrey Semashev 2024. + * 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) + */ +/*! + * \file functor_compile_fail_adl.cpp + * \author Andrey Semashev + * \date 02.02.2024 + * + * This file tests that \c boost::core::functor doesn't bring namespace + * boost::core into ADL. + */ + +#include + +void func() {} + +namespace boost::core { + +void check_adl(functor< ::func > const&) +{ +} + +} // namespace boost::core + +int main() +{ + // Must not find boost::check_adl + check_adl(boost::core::functor< ::func >()); +}