When I attempt this:
string msm_arg1;
…
if (msm_arg1 = "--console" )
run_console();
I get:
res/functions/ReadArgs.h|40|error: could not convert ‘msm_arg1.std::basic_string<_CharT, _Traits, _Alloc>::operator= [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>, std::basic_string<_CharT, _Traits, _Alloc> = std::basic_string<char>](((const char*)"-c"))’ from ‘std::basic_string<char>’ to ‘bool’|
What I’m seeing is that it is trying to compare a string (msm_arg1) to a bool, which “–console” clearly isn’t.
I can see one possible way around: creating a string to compare to, but with plently of possible CLI arguments, that could become messy.
I am using Code::Blocks on Ubuntu 11:10 with the default gcc.
=is the assignment operator.At present, your code does this:
The equivalence operator in C++ is
==:Also it’s worth being aware that this is a case-sensitive comparison, and that it won’t work properly at all if you stop using
std::stringand attempt to compare two literals.