Skip to content

[BUG] no match for operator<< and const cpp2::nonesuch_ #961

Closed
@wolfseifert

Description

@wolfseifert

After pulling in 510eae8:

main: () = {
  a: std::any = 1;
  std::cout << a as int << std::endl;
  std::cout << a as int << std::endl;
}

transpiles to

#define CPP2_IMPORT_STD          Yes
#include "cpp2util.h"
auto main() -> int;
auto main() -> int{
  std::any a {1}; 
  std::cout << cpp2::as_(a) << std::endl;
  std::cout << cpp2::as_(std::move(a)) << std::endl;
}

but does not compile

anys.cpp:10:13: error: no match for ‘operator<<’ (operand types are ‘std::ostream’ {aka ‘std::basic_ostream’} and ‘const cpp2::nonesuch_’)
   10 |   std::cout << cpp2::as_(a) << std::endl;
      |   ~~~~~~~~~ ^~ ~~~~~~~~~~~~~~~~~
      |        |                     |
      |        |                     const cpp2::nonesuch_
      |        std::ostream {aka std::basic_ostream}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions