I am currently porting C++ code that works on Linux (GCC) to Windows (MSVC). I came across some code that I supposed should work.
Let's say we have some class that defines an at method that only accepts integral values:
#include <concepts>
struct foo {
auto at(std::integral auto const... is) const {}
};
(I will use structs to make everything public by default.)
Now we derive bar from foo that overwrites the at method with another at method that only accepts floating point values:
struct bar : foo {
auto at(std::floating_point auto const... is) const {}
};
No I thought if I add using foo::at; in bar, foos at method should become available in bar.
struct bar : foo {
using foo::at; // THIS LINE IS NEW
auto at(std::floating_point auto const... is) const {}
};
If I now call the at method with some ints on an instance of bar GCC, Clang and MSVC do not seem to agree on if that's possible or not. Only GCC compiles this code. Clang and MSVC basically say that they cannot find an at that takes ints.
auto main() -> int {
auto const f = bar{};
f.at(2,3); // Only works with GCC
}
(See here on compiler explorer)
QUESTIONS
Which compiler is wrong or right?
Is there a solution for all compilers?
If I got it right from the standard specification GCC seems to be wrong and Clang and MSVC correctly do not compile the code. Am I right?