rad*_*dix 6 c++ well-formed ambiguous-call language-lawyer overload-resolution
据我了解,函数名称使用的结果可能是以下之一:
\n= deleted, protected/private or, perhaps, something else) \xe2\x80\x94 the overall call is ill-formed.The question is: How to reliably tell apart outcome #2.2 (at least some of its cases) from outcomes #1.2 and #3 (at least one of them) in the case of implicit usage of operator () (i.e. c(a...)) by means of a type trait that accepts the types of the arguments (including c) to be used in the call?
(I\'m not interested in outcomes #1.1 and #2.1 as I know that #1.1 does not hold in my particular use case and #2.1 is easily detectable through SFINAE.)
\nA specific example. How to implement a type trait that looks something like the following
\n/// Would `c(a...)` result in exactly one best viable candidate?\n/// (Where `decltype(c)`, `decltype(a)...` are `C`, `A...`, respectively.)\ntemplate<class C, typename... A>\ninline constexpr bool has_exactly_one_best_viable_call_candidate;\nRun Code Online (Sandbox Code Playgroud)\nso the following asserts hold?
\nstruct WithNoViable {\n void operator ()(void *);\n};\n\nstruct WithDeleted {\n void operator ()(long) = delete;\n};\n\nstruct WithAmbiguity {\n void operator ()(long);\n void operator ()(long long);\n};\n\nstatic_assert(!has_exactly_one_best_viable_call_candidate<WithNoViable, int>);\nstatic_assert( has_exactly_one_best_viable_call_candidate<WithDeleted, int>);\nstatic_assert(!has_exactly_one_best_viable_call_candidate<WithAmbiguity, int>);\nRun Code Online (Sandbox Code Playgroud)\nNote that in general nothing is known about the types of parameters nor arguments.
\n