
hi There is a correction in my snippet that i attached for enable_if. The correct snippet is //primary class template <std::size_t size , template<std::size_t size,typename E = void > class USER_TYPE = select_type > class my_class { public: //Primary class //Note that the select_type is default for USER_TYPE }; //Specialized class template <std::size_t size , template<std::size_t size,typename E = void > class USER_TYPE > class my_class< size,SER_TYPE> { 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<size,void>::type data_type; //THIS WORKS }; --------------------------------------------------------------------------------------------------------- Rgds ----- Forwarded by Suresh T/BTC/SC/PHILIPS on 08/08/2005 02:03 PM ----- hi I am using the boost::enable_if for selection of types. Something similar to below template<std::size_t Size,class Enable = void> struct type_select{ }; template<std::size_t Size> struct type_select< Size, typename boost::enable_if < bool_ < (size <= 8) >
>::type >{ typedef typename char type; }; template<std::size_t Size> 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 <std::size_t size , template<std::size_t size,typename E = void > 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<size,void>::type data_type; //THIS WORKS }; Thanks for clarification in advance.. --------------------------------------------------------------------------------------------------------- Rgds, Suresh