Yeah, I dont think this would work for std::string, either. C++ 'switch' just isn't as general as you might want here.
On October 12, 2018 3:53:54 AM PDT, "Søren Ragsdale" <[email protected]> wrote: >Is there any way to use an OIIO::ustring in a switch statement? I'm >guessing that it's not possible because the hashes for these strings >are >generated at compile time. > >const static OIIO::ustring foo("foo"); >const static OIIO::ustring bar("bar"); >switch (foo) { >case foo: break; >case bar: break; >default: break; >} > >error: the value of ‘foo’ is not usable in a constant expression >> case foo: break; >> ^ >> note: ‘foo’ was not declared ‘constexpr’ >> const static OIIO::ustring foo("foo"); -- Larry Gritz [email protected]
_______________________________________________ Oiio-dev mailing list [email protected] http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
