If you only want to 'switch' the hash of ustring/string, I think it's possible. 
You can implement a compile-time script to generate static hash values for 
'case'. The compare of ustring is based on run-time allocated pointers, using 
if-else-if sequence to compare is very fast. So I suspect if using switch-case 
can get any benefits. ------------------ ???????? ------------------
??????: "S&#xF8;ren Ragsdale"<[email protected]>
????????: 2018??10??12??(??????) ????6:53
??????: "OpenImageIO developers"<[email protected]>;
????: [Oiio-dev] OIIO::ustring in switch statement


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
&#xA0; case foo: break;
&#xA0; &#xA0; &#xA0; &#xA0;^
note: ??foo?? was not declared ??constexpr??
&#xA0;const static OIIO::ustring foo("foo");
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to