It is unclear why the code below does not compile with GCC g++ 4.7 telling the following:
$ g++ -std=c++11 -fPIC test.cpp
test.cpp:11:45: error: ‘B operator"" _b(const char*, size_t)’ has invalid argument list
If class C is declared non-template then it compiles fine.
#include <cstddef>
struct B{};
B operator+(B, B) { return B(); }
B operator"" _b(const char *, size_t) { return B(); }
template<typename T>
class C
{
friend B operator+(B, B);
friend B operator"" _b(const char *, size_t);
};
int main() { return 0; }
What is wrong with this code? Or is it a compiler bug?
Or is it a compiler bug?
This code is correct, as the signature of the operator function is explicitly allowed by the standard - see §13.5.8/3. So it is a GCC-Bug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With