我想对boost库中的range\u mutable\u iterator和range\u const\u iterator进行部分专门化,但只针对我不想明确提及的特定类型,而只允许在enable\u if测试条件通过时选择部分专门化。
我当前正在使用MSVC 2008,收到以下错误:
ArrayType
:
template parameter not used or deducible in partial specialization
range_mutable_iterator<
typename enable_if<
mpl::and_<
mpl::has_key<some_type_map, typename remove_const<T>::type>,
mpl::not_<is_const<T> >
>,
ArrayType
>::type
>
使用STLFilt时,请注意对T而不是ArrayType的奇怪引用,我猜STLFilt是说它无法找出T==ArrayType。。?我现在的情况是:
namespace boost {
template<class ArrayType>
struct range_mutable_iterator<
typename enable_if<
mpl::and_<
mpl::has_key<some_type_map, typename remove_const<ArrayType>::type>,
mpl::not_<is_const<ArrayType> >
>,/*and_*/
ArrayType
>::type/*enable_if*/
>
{
typedef MyArrayIterator<
typename mpl::at<some_other_type_map,
typename mpl::at<yet_another_type_map,ArrayType>::type
>::type/*at*/
>/*MyArrayIterator*/ type;
};
}
ThirdPartyArrayClass blah;
MyArrayAdapter<ThirdPartyArrayClass>::iterator iter = boost::begin(blah);
编辑:在尝试了一种不同的方法之后,我从这个答案中删掉了它,我开始接受在这个例子中部分专门化是不可能的,所以我使用了一种不同的方法,包括完全专门化和大量使用Boost.Preprocessor。