large enum and native array indexing

hello,
we have a 3rd party lib which provides an enum OP with some hundred members,
but each member is defined with numbers that are not contiguous.
enum OP { op1=56, op2=6, op3=5 ..... };
We have a performance critical function f that looks like this:
status f( double& result, OP , int thing );
typical usage calls f( result0, op0 ) then f(result1, op1) .... f(resultn, opn)
on the same thing.
these calls, if merged, could have some speedup as there is some repetitive work
done for say op3 and op7.
I then thought of doing
void f( std::map< Op, pair

AMDG Hicham Mouline wrote:
we have a 3rd party lib which provides an enum OP with some hundred members, but each member is defined with numbers that are not contiguous.
enum OP { op1=56, op2=6, op3=5 ..... };
We have a performance critical function f that looks like this:
<snip>
Now, the question is about defining the metafunction Position.
template< OP op > struct Position {}; template<> struct Position<OP5> { const size_t value=4; }; ....
The 3rd party enum OP in the header file I can't change.
Is there a way to generate my metafunction automatically? Any facility in mpl or fusion instead of defining my own metafunction?
I would say that the easiest way is to use the preprocessor.
#define BOOST_PP_LOCAL_MACRO(n) template<> struct
Position
participants (2)
-
Hicham Mouline
-
Steven Watanabe