0

今日は全員ではないかもしれませんが、これをどのように機能させるのか疑問に思っています。Boostライブラリからrange_mutable_iteratorとrange_const_iteratorを部分的に特殊化したいのですが、明示的に言及するのを避けたい特定のタイプに対してのみ、enable_ifテスト基準に合格した場合にのみ部分的な特殊化を選択させます。

現在MSVC2008を使用していますが、次のエラーが発生します
ArrayType:: template parameter not used or deducible in partial specializationon type

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を使用して、ArrayTypeの代わりにTへの奇妙な参照に注意してください。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;
};
}

range_begin / range_endを機能させることは現在のところ問題ではありません。目標は、次のようなラインワークを実現することです。

ThirdPartyArrayClass blah;
MyArrayAdapter<ThirdPartyArrayClass>::iterator iter = boost::begin(blah);

編集:この回答から編集した別のアプローチを試した後、この場合は部分的な特殊化は不可能であると受け入れるようになったので、完全な特殊化と大量の使用を伴う別のアプローチを使用しましたBoost.Preprocessor。

4

1 に答える 1

0

In order to partially specialize a template the compiler must match the actual template arguments to the existing specializations, with the aim to select the best match. This is just not possible if the template argument in the specialization is used just as the (template) parameter to a dependent type. So, the compiler complains, and rightly so. The only thing you can do is to somehow specialize on your concrete ThirdPartyArrayClass type.

于 2010-08-04T01:41:48.757 に答える