Re: [Boost-users] safe assign of int to enum
27 Mar
2006
27 Mar
'06
9:14 p.m.
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Tomas Puverle Sent: Monday, March 27, 2006 12:07 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] safe assign of int to enum
template<typename Enum> typename Enum::type convert_enum(int a) { typedef typename Enum::type type_; assert(a >= Enum::min && a <= Enum::max); return type_(a); }
This won't work for enums where the range is not continuous.
I wrote a library for "smart enums" that allow you to:
I am aware of these limitations :) I vote for post!
6803
Age (days ago)
6803
Last active (days ago)
0 comments
1 participants
participants (1)
-
Sohail Somani