Created on 2024-05-11.00:00:00 last changed 4 months ago
Proposed resolution:
This wording is relative to N4981.
Modify [global.functions] as indicated:
[…]
-2- A call to a non-member function signature described in [support] through [thread] and [depr] shall behave as if the implementation declared no additional non-member function signatures. However, for each non-member function specified with at least one default argument, an implementation may declare additional function signatures with one or more trailing parameters that have default arguments removed. [Example 1: The following program is possibly ill-formed because of ambiguity in overload resolution.#include <cstddef> #include <string> // One overload of std::stoi ([string.conversions]) is specified as // int stoi(const string& str, size_t* idx = nullptr, int base = 10); // An implementation can declare these overloads instead of using default arguments: // int stoi(const string& str, size_t* idx, int base); // int stoi(const string& str, size_t* idx); // int stoi(const string& str); namespace usr { int stoi(const std::string&); int stoi(const std::string&, std::size_t*); } int main() { using std::stoi; using usr::stoi; int (*p1)(const std::string&) = stoi; // possibly ill-formed int (*p2)(const std::string&, std::size_t*) = stoi; // possibly ill-formed }— end example]
[ 2024-08-02; Reflector poll ]
Set priority to 3 after reflector poll. "It's a lot of new text just to say you can't do that, lose the example?" "Might be NAD, is this already disallowed?" "Only for member functions."
Currently, std::from_chars and std::to_chars are specified with default arguments. Some implementors want to split them into more overloads to determine the base 10 at compile time (LLVM issue #91268). However, the current standard wording doesn't clearly allow such technique.
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-08-02 21:52:03 | admin | set | messages: + msg14289 |
2024-05-12 12:03:21 | admin | set | messages: + msg14138 |
2024-05-11 00:00:00 | admin | create |