You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Both libstdc++ and libc++ use ADL for all these functions.
Command-line test case
STL version (git commit or Visual Studio version): 19.24.28218.2
D:\>type test.cpp
#include <valarray>
namespace ns {
struct A {};
A abs(A);
A sqrt(A);
}
int main() {
std::valarray<ns::A> a;
(void)std::abs(a);
(void)std::sqrt(a);
}
D:\>cl /c test.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.24.28218.2 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
test.cpp
D:\...\valarray(836): error C2665: 'sqrt': none of the 3 overloads could convert all the argument types
D:\...\cmath(485): note: could be 'long double sqrt(long double) noexcept'
D:\...\cmath(241): note: or 'float sqrt(float) noexcept'
D:\Windows Kits\10\include\10.0.17763.0\ucrt\corecrt_math.h(485): note: or 'double sqrt(double)'
D:\...\valarray(836): note: while trying to match the argument list '(const _Ty)'
with
[
_Ty=ns::A
]
test.cpp(11): note: see reference to function template instantiation 'std::valarray<ns::A> std::sqrt<ns::A>(const std::valarray<ns::A> &)' being compiled
Expected behavior
No error.
Additional context
N/A
The text was updated successfully, but these errors were encountered:
Requires: Each of these functions may only be instantiated for a type T to which a unique function with the indicated name can be applied (unqualified).
This function shall return a value which is of type T or which can be unambiguously implicitly converted to type T.
So each of those functions should be indeed called unqualified.
Describe the bug
Non-member functions in <valarray> are inconsistent about whether to use ADL.
abs
enables ADL:STL/stl/inc/valarray
Lines 749 to 752 in f9b1dcc
Other functions disable ADL by qualify the function call with
_CSTD
. For example:STL/stl/inc/valarray
Lines 834 to 837 in f9b1dcc
Both libstdc++ and libc++ use ADL for all these functions.
Command-line test case
STL version (git commit or Visual Studio version): 19.24.28218.2
Expected behavior
No error.
Additional context
N/A
The text was updated successfully, but these errors were encountered: