Based on this question:
"enum class" emulation or solid alternative for MSVC 10.0
I would like to ask a couple of things. Assuming this code:
struct DeletionMode_E
{
static DeletionMode_E const Off;
static DeletionMode_E const DirSize;
static DeletionMode_E const FileNumberSize;
static DeletionMode_E const DirAndFileNumberSize;
operator int const() const { return myVal; }
private:
explicit DeletionMode_E(const int & v) : myVal(v) { }
const int myVal;
};
And their subsequent definitions :
Log4Reconstruction::DeletionMode_E const Log4Reconstruction::DeletionMode_E::Off(0);
Log4Reconstruction::DeletionMode_E const Log4Reconstruction::DeletionMode_E::DirSize(1);
Log4Reconstruction::DeletionMode_E const Log4Reconstruction::DeletionMode_E::FileNumberSize(2);
Log4Reconstruction::DeletionMode_E const Log4Reconstruction::DeletionMode_E::DirAndFileNumberSize(3);
One can use this like :
void Log4Reconstruction::setDeletionMode( Log4Reconstruction::DeletionMode_E const & delMode_in)
{
std::cout << delMode_in << std::endl;
switch(delMode_in)
{
//case Log4Reconstruction::DeletionMode_E::Off: C2051 case expression not constant
// std::cout << "Off" << std::endl;
// break;
case 1:
std::cout << "File number" << std::endl;
break;
}
}
Why is the function call operator called? How would one call it manually in order to solve the "problem" in the case statement? I am using MSVS 2008 no external libs are available.