You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
auto cli
= session.cli() // Get Catch2's command line parser
| Opt( height, "height" ) // bind variable to a new option, with a hint string
["-g"]["--height"] // the option names it will respond to
("how high?"); // description string for the help output
That does not compile anymore in 3.5.1. It used to work in 3.5.0.
In file included from /home/snapwebsites/snapcpp/BUILD/Debug/dist/include/catch2/internal/catch_commandline.hpp:11,
from /home/snapwebsites/snapcpp/BUILD/Debug/dist/include/catch2/catch_session.hpp:11,
from /home/snapwebsites/snapcpp/BUILD/Debug/dist/include/catch2/snapcatch2.hpp:29,
from /home/snapwebsites/snapcpp/contrib/libexcept/tests/catch_main.h:23,
from /home/snapwebsites/snapcpp/contrib/libexcept/tests/catch_main.cpp:25:
/home/snapwebsites/snapcpp/BUILD/Debug/dist/include/catch2/internal/catch_clara.hpp: In instantiation of ‘Catch::Clara::Parser Catch::Clara::operator|(const Catch::Clara::Parser&, T&&) [with T = Catch::Clara::Opt]’:
/home/snapwebsites/snapcpp/contrib/libexcept/tests/catch_main.cpp:59:115: required from here
/home/snapwebsites/snapcpp/BUILD/Debug/dist/include/catch2/internal/catch_clara.hpp:676:24: error: cannot bind non-const lvalue reference of type ‘Catch::Clara::Parser&’ to an rvalue of type ‘Catch::Clara::Parser’
676 | return Parser( p ) |= CATCH_FORWARD(rhs);
| ^~~~~~~~~~~
/home/snapwebsites/snapcpp/BUILD/Debug/dist/include/catch2/internal/catch_clara.hpp:667:48: note: initializing argument 1 of ‘Catch::Clara::Parser& Catch::Clara::operator|=(Catch::Clara::Parser&, Catch::Clara::Opt&&)’
667 | friend Parser& operator|=( Parser& p, Opt&& opt ) {
| ~~~~~~~~^
which says that the value on the left side needs to be a variable.
I could change the code this way to make it compile:
auto cli = session.cli() // Get Catch2's command line parser
cli |= Opt( height, "height" ) // bind variable to a new option, with a hint string
["-g"]["--height"] // the option names it will respond to
("how high?"); // description string for the help output
Thanks for the workaround @AlexisWilke. I have similar code that has been working for years but is now giving the same compilation error you posted, I'm guessing a brew upgrade was what triggered the issue for me. Separating the construction of the cli object from the operator |= seems better all around and compiles fine.
Describe the bug
As per this documentation I can add my own options in this way:
That does not compile anymore in 3.5.1. It used to work in 3.5.0.
which says that the value on the left side needs to be a variable.
I could change the code this way to make it compile:
Expected behavior
No error compiling code.
Reproduction steps
See above.
Platform information:
Additional context
I use the
-std=g++23
command line option to compile my code.The text was updated successfully, but these errors were encountered: