https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99692

            Bug ID: 99692
           Summary: Lookup for operator<< skips global scope
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: skaniskin at berkeley dot edu
  Target Milestone: ---

The following code is rejected by g++. 

#include <ostream>
#include <vector>

struct CustomStream : std::ostream {};

std::ostream& operator<<(std::ostream& s, const std::vector<int>&) 
{
    return s;
}

CustomStream&& operator<<(CustomStream&& s, const std::vector<int>& v)  
{
    static_cast<std::ostream&>(s) << v;
    return std::move(s);
}

int main() 
{
    CustomStream() << std::vector<int>{};
}

The problem is there with all recent versions of gcc and independent of
compiler flags

Reply via email to