Date: Sun, 26 Feb 2023 22:47:41 +0000
> is there any proposal in the works for switch on strings?
I think the first thing you need to clarify is as follows:
Does each 'case' statement need to be a compile time constant?
For example, even when using 'switch' with integers, we can't do:
switch ( arg )
{
case 0:
case 1:
case 2:
case g_some_global_variable: ;
}
This code won't compile if "g_come_global_variable" isn't a
compile-time constant.
So if a 'switch' statement could work with strings, would the strings
need to be compile-time const arrays of char's?
I think the first thing you need to clarify is as follows:
Does each 'case' statement need to be a compile time constant?
For example, even when using 'switch' with integers, we can't do:
switch ( arg )
{
case 0:
case 1:
case 2:
case g_some_global_variable: ;
}
This code won't compile if "g_come_global_variable" isn't a
compile-time constant.
So if a 'switch' statement could work with strings, would the strings
need to be compile-time const arrays of char's?
Received on 2023-02-26 22:47:54