https://bugs.kde.org/show_bug.cgi?id=360567

Matt Whitlock <k...@mattwhitlock.name> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |k...@mattwhitlock.name

--- Comment #2 from Matt Whitlock <k...@mattwhitlock.name> ---
(In reply to Alexander Potashev from comment #0)
> In the sample code below, pressing Ctrl+Space shows "void print()". "void
> print()" is just wrong here, these two options should be displayed instead:
>  * void print(int a, char b)
>  * void print(std::string a, double b)

Your suggestion is wrong. The compiler is in fact free to instantiate the
variadic function template using *any* template parameters whatsoever. It is
true that there will be a compilation error for any but two distinct tuples of
argument types, but this has no bearing on the parameters with which the
template may be instantiated.

What you're asking for is effectively that the contextual assistant should
compute the set containing all tuples of argument types that would not result
in a compilation error, but this may in fact be an infinite set, and in general
there is no way to guess what type tuples might be in the set.

Consider the following addition to your example:

template <typename E>
std::enable_if_t<std::is_enum_v<E>, void> print_impl(E value) {
    std::cout << static_cast<std::underlying_type_t<E>>(value);
}

Now what is the contextual assistant supposed to show when you press
Ctrl+Space? Do you expect it to search through every defined type, trying to
instantiate the print_impl(E) function template? Do you expect every defined
enumerated type to appear in the list of suggestions? That would be pretty
impractical.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to