-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
The operator<<
does not work for std::stringstream
and various spy classes since the switch to C++20.
To Reproduce
#include <sstream>
#include <spy/spy.hpp>
int main()
{
std::stringstream str;
str << spy::operating_system << std::endl;
str << spy::architecture << std::endl;
str << spy::simd_instruction_set << std::endl;
str << spy::compiler << std::endl;
str << spy::libc << std::endl;
str << spy::stdlib << std::endl;
}
Building with GCC 15.1.1:
FAILED: CMakeFiles/example.dir/example.cpp.o
/usr/bin/c++ -I/home/lahwaacz/build/_deps/spy-src/include -O2 -g -DNDEBUG -std=c++20 -MD -MT CMakeFiles/example.dir/example.cpp.o -MF CMakeFiles/example.dir/example.cpp.o.d -fmodules-ts -fmodule-mapper=CMakeFiles/example.dir/example.cpp.o.modmap -MD -fdeps-format=p1689r5 -x c++ -o CMakeFiles/example.dir/example.cpp.o -c /home/lahwaacz/example.cpp
In file included from /home/lahwaacz/build/_deps/spy-src/include/spy/spy.hpp:45,
from /home/lahwaacz/example.cpp:2:
/home/lahwaacz/build/_deps/spy-src/include/spy/os.hpp: In instantiation of ‘OS& spy::_::operator<<(OS&, const os_info<OpSys>&) [with OS = std::__cxx11::basic_stringstream<char>; systems OpSys = spy::_::systems::linux_]’:
/home/lahwaacz/example.cpp:7:15: required from here
7 | str << spy::operating_system << std::endl;
| ^~~~~~~~~~~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/os.hpp:40:50: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
40 | if (OpSys == systems::android_) return os << "Android";
| ^~~~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/os.hpp:41:46: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
41 | if (OpSys == systems::bsd_) return os << "BSD";
| ^~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/os.hpp:42:49: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
42 | if (OpSys == systems::cygwin_) return os << "Cygwin";
| ^~~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/os.hpp:43:46: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
43 | if (OpSys == systems::ios_) return os << "iOs";
| ^~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/os.hpp:44:48: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
44 | if (OpSys == systems::linux_) return os << "Linux";
| ^~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/os.hpp:45:48: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
45 | if (OpSys == systems::macos_) return os << "MacOs";
| ^~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/os.hpp:46:47: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
46 | if (OpSys == systems::unix_) return os << "UNIX";
| ^~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/os.hpp:47:50: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
47 | if (OpSys == systems::windows_) return os << "Windows";
| ^~~~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/os.hpp:49:18: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
49 | return os << "Undefined Operating System";
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/lahwaacz/build/_deps/spy-src/include/spy/spy.hpp:41:
/home/lahwaacz/build/_deps/spy-src/include/spy/arch.hpp: In instantiation of ‘OS& spy::_::operator<<(OS&, const arch_info<Arch>&) [with OS = std::__cxx11::basic_stringstream<char>; archs Arch = spy::_::archs::amd64_]’:
/home/lahwaacz/example.cpp:8:15: required from here
8 | str << spy::architecture << std::endl;
| ^~~~~~~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/arch.hpp:33:45: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
33 | if (Arch == archs::x86_) return os << "X86";
| ^~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/arch.hpp:34:47: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
34 | if (Arch == archs::amd64_) return os << "AMD64";
| ^~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/arch.hpp:35:45: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
35 | if (Arch == archs::ppc_) return os << "PowerPC";
| ^~~~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/arch.hpp:36:45: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
36 | if (Arch == archs::arm_) return os << "ARM";
| ^~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/arch.hpp:37:46: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
37 | if (Arch == archs::wasm_) return os << "WebAssembly";
| ^~~~~~~~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/arch.hpp:38:47: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
38 | if (Arch == archs::riscv_) return os << "RISC-V";
| ^~~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/arch.hpp:40:20: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
40 | return os << "Undefined Architecture";
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/lahwaacz/build/_deps/spy-src/include/spy/spy.hpp:42:
/home/lahwaacz/build/_deps/spy-src/include/spy/compiler.hpp: In instantiation of ‘OS& spy::_::operator<<(OS&, const compilers_info<C, M, N, P>&) [with OS = std::__cxx11::basic_stringstream<char>; compilers C = spy::_::compilers::gcc_; int M = 15; int N = 1; int P = 1]’:
/home/lahwaacz/example.cpp:10:15: required from here
10 | str << spy::compiler << std::endl;
| ^~~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/compiler.hpp:49:74: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
49 | if (C == compilers::nvcc_) return os << "NVIDIA CUDA Compiler " << c.version;
| ^~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/compiler.hpp:50:77: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
50 | if (C == compilers::msvc_) return os << "Microsoft Visual Studio " << c.version;
| ^~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/compiler.hpp:51:76: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
51 | if (C == compilers::intel_) return os << "Intel(R) C++ Compiler " << c.version;
| ^~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/compiler.hpp:52:89: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
52 | if (C == compilers::dpcpp_) return os << "Intel(R) oneAPI DPC++/C++ Compiler " << c.version;
| ^~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/compiler.hpp:53:60: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
53 | if (C == compilers::clang_) return os << "clang " << c.version;
| ^~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/compiler.hpp:54:56: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
54 | if (C == compilers::gcc_) return os << "g++ " << c.version;
| ^~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/compiler.hpp:55:70: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
55 | if (C == compilers::emscripten_) return os << "Emscripten " << c.version;
| ^~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/compiler.hpp:57:36: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
57 | return os << "Undefined " << c.version;
| ^~~~~~~
In file included from /home/lahwaacz/build/_deps/spy-src/include/spy/spy.hpp:44:
/home/lahwaacz/build/_deps/spy-src/include/spy/libc.hpp: In instantiation of ‘OS& spy::_::operator<<(OS&, const libc_info<C, M, N, P>&) [with OS = std::__cxx11::basic_stringstream<char>; libC C = spy::_::libC::gnu_; int M = 2; int N = 41; int P = 0]’:
/home/lahwaacz/example.cpp:11:15: required from here
11 | str << spy::libc << std::endl;
| ^~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/libc.hpp:41:87: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
41 | if (c.vendor == libC::cloudabi_) return os << "CloudABI Standard C Library " << c.version;
| ^~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/libc.hpp:42:79: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
42 | if (c.vendor == libC::uc_) return os << "uClibc Standard C Library " << c.version;
| ^~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/libc.hpp:43:77: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
43 | if (c.vendor == libC::vms_) return os << "VMS Standard C Library " << c.version;
| ^~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/libc.hpp:44:78: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
44 | if (c.vendor == libC::zos_) return os << "z/OS Standard C Library " << c.version;
| ^~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/libc.hpp:45:77: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
45 | if (c.vendor == libC::gnu_) return os << "GNU Standard C Library " << c.version;
| ^~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/libc.hpp:47:18: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
47 | return os << "Undefined Standard C Library";
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/lahwaacz/build/_deps/spy-src/include/spy/spy.hpp:48:
/home/lahwaacz/build/_deps/spy-src/include/spy/stdlib.hpp: In instantiation of ‘OS& spy::_::operator<<(OS&, const stdlib_info<SLib, M, N, P>&) [with OS = std::__cxx11::basic_stringstream<char>; stdlib SLib = spy::_::stdlib::gnucpp_; int M = 2025; int N = 4; int P = 25]’:
/home/lahwaacz/example.cpp:12:15: required from here
12 | str << spy::stdlib << std::endl;
| ^~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/stdlib.hpp:41:83: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
41 | if (SLib == stdlib::libcpp_) return os << "libc++ Standard C++ Library " << p.version;
| ^~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/stdlib.hpp:42:80: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
42 | if (SLib == stdlib::gnucpp_) return os << "GNU Standard C++ Library " << p.version;
| ^~~~~~~
/home/lahwaacz/build/_deps/spy-src/include/spy/stdlib.hpp:44:18: error: invalid initialization of reference of type ‘std::__cxx11::basic_stringstream<char>&’ from expression of type ‘std::basic_ostream<char>’
44 | return os << "Undefined Standard C++ Library";
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
Expected behavior
The example should work (same as before spy switched to C++20).
Setup:
- Compiler and compiler's version: g++ 15.1.1
- OS: Arch Linux
jfalcou
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working