| -----Original Message-----
| From: Ville Voutilainen <[email protected]>
| Sent: Monday, June 8, 2020 2:19 PM
| To: Richard Smith <[email protected]>
| Cc: [email protected]; Marek Polacek <[email protected]>;
| [email protected]; Gabriel Dos Reis <[email protected]>
| Subject: Re: [SG10] [isocpp-core] Feature-test macro for ADL calls with
| template arguments?
| 
| On Tue, 9 Jun 2020 at 00:01, Richard Smith <[email protected]>
| wrote:
| > I thought the usual way you write ADL-only calls is
| >
| > template<typename T> void f(T t) {
| >   using somewhere::name;
| >   name(t); // ADL-only call with fallback to somewhere::name
| > }
| 
| The "name" in this case is "get", and it needs to be called with a
| numeric template argument.
| 
| > (eg, this is how I think we would recommend that people call 'begin' and
| 'end': "using std::begin; begin(x);"). I think that works equally well if
| 'somewhere' contains a function template, even if you don't have anything
| to put in namespace 'somewhere':
| >
| > namespace somewhere {
| >   template<typename T> void name(...) = delete; // specialization missing
| > }
| > template<typename T> void f(T t) {
| >   using somewhere::name;
| >   name<int>(t); // ADL-only call with fallback to somewhere::name
| > }
| >
| > This works without a feature test macro, and is more reliable than relying
| on the new feature. (For example, the above pattern is not broken if
| someone incautiously adds a non-function, non-function-template 'name' to
| a scope enclosing 'f', whereas use of the new feature would be broken by
| that.)
| 
| All we want is to be able to write QPair<What, Ever> qp; get<1>(qp);
| 
| I don't know what that "somewhere" would be, nor do I know why I'd
| write a using-declaration for somewhere::get.

For the configuration of Qt that does not use namespaces, there is no 
"somewhere"; name lookup just finds it.

-- Gaby

-- 
SG10 mailing list
[email protected]
https://lists.isocpp.org/mailman/listinfo.cgi/sg10

Reply via email to