Why doesn't the dependency-dependent search take into account Foo::dynamicCastwhether the Foo namespace should be considered, because the Base class is in this namespace?
Foo::dynamicCast
#include <memory> using namespace std; namespace Foo { template<typename P, typename T> P* dynamicCast(T* t) { return dynamic_cast<P*>(t); } class Base { public: virtual ~Base() = default; }; } namespace Test { class Derived : public Foo::Base { }; } shared_ptr<Foo::Base> b = make_shared<Test::Derived>(); auto d = dynamicCast<Test::Derived>(b.get());
, , < >, , ; , , , . , , . , , . , , , , . , . . ?
<
>
- ADL , -id. dynamicCast<Test::Derived> not <edit> , dynamicCast , , , .
dynamicCast<Test::Derived>
dynamicCast
@T.C. , dynamicCast, ADL.
</edit>
template foo<whatever> . , ++ 20.
template foo<whatever>
ADL. , , .
std::get. get<3>(some_tuple) .
std::get
get<3>(some_tuple)
, , args . - , ADL- ( , ADL ).
// tag utilities: template<class T>struct tag_t{using type=T;constexpr tag_t(){};}; template<class T>constexpr tag_t<T> tag={}; namespace some{ template<class T, class U> T* dynamic(tag_t<T>, U* u){ return dynamic_cast<T>(u); } struct bob{}; }
dynamic(tag<int>,new some::bob{}) dynamic ADL.
dynamic(tag<int>,new some::bob{})
dynamic
.
Source: https://habr.com/ru/post/1617489/More articles:When to use subprocess.call () or subprocess.Popen (), starts airodump - pythonUpdating part of a shared variable in Theano - pythonHow to track / debug this SOAP error [message: protected] => it looks like we donβt have an XML document - androidHow does angularjs.forEach () work? - javascriptXitode UITest Record Button Disabled - iosCheck if the method implements the interface method marked with the attribute - c #AngularJS - Ng-Table will not parse headers - javascriptshow git to view previous version of renamed file? - gitRunning jar application file on spark-submit in google dataproc cluster instance - javaWebservice - How to pass timezone information in a datetime element - c #All Articles