Boost logo

Boost :

Subject: [boost] detect an enum type in template arguments
From: Aston (blackapache512-ticket_at_[hidden])
Date: 2011-03-03 01:32:47


Hi, consider the example below, is there a way to detect an enum type and non-enum type ? thus if there were a way to do it, assume it to be "is_enum<T>::value" then the output of example below would have been output: Generic Type Enumeration Type **************************** example begins *************************** // all types except enumeration come here template T> class Foo { void identify() { std::cout << "Generic"; } }; // all enumerations types come here <template T> class Foo<is_enum<T>::value> { void identify() { std::cout << "Enumeration"; } }; enum BarEnum { Mon, Tue, Wed }; int main( int argc, char* argv[]) { std::cout << Foo<int> << " Type" << std::endl; std::cout << Foo<BarEnum> << " Type" << std::endl; return 0; } **************************** example ends *************************** Aston


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