hi
I am using the boost::enable_if for selection of types. Something similar
to below
template
struct type_select{
};
template
struct type_select< Size,
typename boost::enable_if < bool_ < (size <= 8) >
>::type
>{
typedef typename char type;
};
template
struct type_select< Size,
typename boost::enable_if < bool_ < (size > 8) > >
>::type
>{
typedef typename int type;
};
The conditions are based on the first parameter size. The normal usage
would be something like type_select<10>::type;
My question is : If i explicitly use the second parameter ( by passing
void) will the correct specialization be still used
i.e, if i use say type_select<6,void>::type, will it resolve to
"char" in the above case.
Please note: I was using the normal way (without the void) for my code
on linux+gcc without any problems
My problem came up when i tried to move my code to windows + vc7.1.
The vc7.1 compiler needs the second argument (in my usage shown below )
else it gives an error. The results are as desired, but i would like
to know whether this usage is correct.
Below is a snippet where the vc7.1 compiler gives a problem with the
usage.
Note type_select is not directly used but is used as a default type for
USER_TYPE parameter
template class USER_TYPE
>
class my_class
< size,
USER_TYPE = select_type //select_type is a default parameter
> {
public:
//The commented code line below does not work for VC7.1
// typedef typename USER_TYPE<size>::type data_type; //THIS
DOES NOT WORK with vc7.1
typedef typename USER_TYPE::type data_type; //THIS
WORKS
};
Thanks for clarification in advance..
---------------------------------------------------------------------------------------------------------
Rgds,
Suresh