Boost logo

Boost :

Subject: [boost] [switch] Is there any interest in library switch extention?
From: Kasra \(Math & ComSci\) (kasra_n500_at_[hidden])
Date: 2008-09-14 08:30:03


Hello to all;

I came up with an idea of extending the current switch functionality using library extensions. The problem is mostly when we have char[] (or any other object) in the switch statement:

void do_switch(const char *cstr) {
        switch( cstr )
        {
        case "Sunday": case "Saturday":
        ...
        break;
        case "Monday":
        ...
        };
}

Obviously we can't do this using C++ alone, so if we have something like BOOST_SWITCH() which would accomplish this would be great.
I have a runtime solution (with need of some attention) for this, however, a compile time solution is desirable.

The library should do something like:

BOOST_SWITCH( "hello world" )
{
        BOOST_CASE( "hello" ):
        BOOST_CASE( "world" ):
        ...
        break;
        BOOST_DEFAULT:
        ...
};

(Please don't suggest 'enum' solutions since they are not as dynamic and are confined to very small domain)
Any suggestions, ideas & etc?

With best regards Kasra

      


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk