Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:51:17

0001 #ifndef BOOST_RANGE_DETAIL_MICROSOFT_HPP
0002 #define BOOST_RANGE_DETAIL_MICROSOFT_HPP
0003 
0004 // Boost.Range MFC/ATL Extension
0005 //
0006 // Copyright Shunsuke Sogame 2005-2006.
0007 // Distributed under the Boost Software License, Version 1.0. 
0008 // (See accompanying file LICENSE_1_0.txt or copy at 
0009 // http://www.boost.org/LICENSE_1_0.txt)
0010 
0011 
0012 
0013 
0014 // config
0015 //
0016 
0017 
0018 #include <boost/range/iterator.hpp>
0019 
0020 
0021 #define BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1 1
0022 
0023 
0024 #if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
0025     #define BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator range_mutable_iterator
0026     #define BOOST_RANGE_DETAIL_MICROSOFT_range_begin            range_begin
0027     #define BOOST_RANGE_DETAIL_MICROSOFT_range_end              range_end
0028 #else
0029     #define BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator range_mutable_iterator
0030     #define BOOST_RANGE_DETAIL_MICROSOFT_range_begin            range_begin
0031     #define BOOST_RANGE_DETAIL_MICROSOFT_range_end              range_end
0032 #endif
0033 
0034 
0035 
0036 
0037 // yet another customization way
0038 //
0039 
0040 
0041 #include <boost/iterator/iterator_traits.hpp> // iterator_difference
0042 #include <boost/mpl/identity.hpp>
0043 #include <boost/mpl/if.hpp>
0044 #include <boost/preprocessor/cat.hpp>
0045 #include <boost/preprocessor/control/iif.hpp>
0046 #include <boost/preprocessor/comma_if.hpp>
0047 #include <boost/preprocessor/detail/is_unary.hpp>
0048 #include <boost/preprocessor/list/for_each.hpp>
0049 #include <boost/preprocessor/repetition/enum_params.hpp>
0050 #include <boost/preprocessor/repetition/repeat.hpp>
0051 #include <boost/preprocessor/seq/for_each_i.hpp>
0052 #include <boost/preprocessor/seq/size.hpp>
0053 #include <boost/preprocessor/tuple/eat.hpp>
0054 #include <boost/range/const_iterator.hpp>
0055 #include <boost/range/size_type.hpp>
0056 #include <boost/type_traits/is_const.hpp>
0057 #include <boost/type_traits/is_same.hpp>
0058 #include <boost/type_traits/remove_cv.hpp>
0059 #include <boost/utility/addressof.hpp>
0060 #include <boost/utility/enable_if.hpp> // disable_if
0061 #include <boost/next_prior.hpp>
0062 
0063 #if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
0064     #include <boost/range/mutable_iterator.hpp>
0065 #else
0066     #include <iterator> // distance
0067     #include <boost/range/begin.hpp>
0068     #include <boost/range/end.hpp>
0069     #include <boost/range/iterator.hpp>
0070 #endif
0071 
0072 
0073 namespace boost { namespace range_detail_microsoft {
0074 
0075 
0076     // customization point
0077     //
0078 
0079     template< class Tag >
0080     struct customization;
0081 
0082 
0083     template< class T >
0084     struct customization_tag;
0085 
0086 
0087     struct using_type_as_tag
0088     { };
0089 
0090 
0091     // Topic:
0092     // In fact, it is unnecessary for VC++.
0093     // VC++'s behavior seems conforming, while GCC fails without this.
0094     template< class Iterator, class T >
0095     struct mutable_ :
0096         disable_if< is_const<T>, Iterator >
0097     { };
0098 
0099 
0100     // helpers
0101     //
0102 
0103     template< class Tag, class T >
0104     struct customization_tag_of
0105     {
0106         typedef typename mpl::if_< is_same<using_type_as_tag, Tag>,
0107             T,
0108             Tag
0109         >::type type;
0110     };
0111 
0112 
0113     template< class T >
0114     struct customization_of
0115     {
0116         typedef typename remove_cv<T>::type bare_t;
0117         typedef typename customization_tag<bare_t>::type tag_t;
0118         typedef customization<tag_t> type;
0119     };
0120 
0121 
0122     template< class T >
0123     struct mutable_iterator_of
0124     {
0125         typedef typename remove_cv<T>::type bare_t;
0126         typedef typename customization_of<bare_t>::type cust_t;
0127         typedef typename cust_t::template meta<bare_t>::mutable_iterator type;
0128     };
0129 
0130 
0131     template< class T >
0132     struct const_iterator_of
0133     {
0134         typedef typename remove_cv<T>::type bare_t;
0135         typedef typename customization_of<bare_t>::type cust_t;
0136         typedef typename cust_t::template meta<bare_t>::const_iterator type;
0137     };
0138 
0139 
0140     template< class T >
0141     struct size_type_of
0142     {
0143         typedef typename range_detail_microsoft::mutable_iterator_of<T>::type miter_t;
0144         typedef typename iterator_difference<miter_t>::type type;
0145     };
0146 
0147 
0148     template< class T > inline
0149     typename mutable_iterator_of<T>::type
0150     begin_of(T& x)
0151     {
0152         typedef typename customization_of<T>::type cust_t;
0153         return cust_t().template begin<typename mutable_iterator_of<T>::type>(x);
0154     }
0155 
0156 
0157     template< class T > inline
0158     typename const_iterator_of<T>::type
0159     begin_of(T const& x)
0160     {
0161         typedef typename customization_of<T>::type cust_t;
0162         return cust_t().template begin<typename const_iterator_of<T>::type>(x);
0163     }
0164 
0165 
0166     template< class T > inline
0167     typename mutable_iterator_of<T>::type
0168     end_of(T& x)
0169     {
0170         typedef typename customization_of<T>::type cust_t;
0171         return cust_t().template end<typename mutable_iterator_of<T>::type>(x);
0172     }
0173 
0174 
0175     template< class T > inline
0176     typename const_iterator_of<T>::type
0177     end_of(T const& x)
0178     {
0179         typedef typename customization_of<T>::type cust_t;
0180         return cust_t().template end<typename const_iterator_of<T>::type>(x);
0181     }
0182 
0183 
0184 #if defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
0185 
0186     template< class T > inline
0187     typename size_type_of<T>::type
0188     size_of(T const& x)
0189     {
0190         return std::distance(boost::begin(x), boost::end(x));
0191     }
0192 
0193 #endif
0194 
0195 
0196     template< class Range >
0197     struct compatible_mutable_iterator : 
0198         BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator<Range>
0199     { };
0200 
0201 
0202 } } // namespace boost::range_detail_microsoft
0203 
0204 
0205 #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open(NamespaceList) \
0206     BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open_op, ~, NamespaceList) \
0207 /**/
0208 
0209     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open_op(r, data, elem) \
0210         namespace elem { \
0211     /**/
0212 
0213 
0214 #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close(NamespaceList) \
0215     BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close_op, ~, NamespaceList) \
0216 /**/
0217 
0218     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close_op(r, data, elem) \
0219         } \
0220     /**/
0221 
0222 
0223 #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_expand_op(r, data, elem) \
0224     :: elem \
0225 /**/
0226 
0227 
0228 #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(Tag, NamespaceList, Name) \
0229     namespace boost { namespace range_detail_microsoft { \
0230         BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_tag(Tag, BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
0231     } } \
0232     \
0233     namespace boost { \
0234         BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_mutable_iterator(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
0235         BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_const_iterator(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
0236         BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size_type(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
0237     } \
0238     \
0239     BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open(NamespaceList) \
0240         BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
0241         BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin_const(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
0242         BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
0243         BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end_const(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
0244         BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name)) \
0245     BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close(NamespaceList) \
0246 /**/
0247 
0248 
0249     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_fullname(NamespaceList, Name) \
0250         BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_expand_op, ~, NamespaceList) :: Name \
0251     /**/
0252 
0253 
0254     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_tag(Tag, Fullname) \
0255         template< > \
0256         struct customization_tag< Fullname > : \
0257             customization_tag_of< Tag, Fullname > \
0258         { }; \
0259     /**/
0260 
0261 
0262     // metafunctions
0263     //
0264 
0265     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_mutable_iterator(Fullname) \
0266         template< > \
0267         struct BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator< Fullname > : \
0268             range_detail_microsoft::mutable_iterator_of< Fullname > \
0269         { }; \
0270     /**/
0271 
0272 
0273     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_const_iterator(Fullname) \
0274         template< > \
0275         struct range_const_iterator< Fullname > : \
0276             range_detail_microsoft::const_iterator_of< Fullname > \
0277         { }; \
0278     /**/
0279 
0280 
0281     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size_type(Fullname) \
0282         template< > \
0283         struct range_size< Fullname > : \
0284             range_detail_microsoft::size_type_of< Fullname > \
0285         { }; \
0286     /**/
0287 
0288 
0289     // functions
0290     //
0291 
0292     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin(Fullname) \
0293         inline \
0294         boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
0295         BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname& x) \
0296         { \
0297             return boost::range_detail_microsoft::begin_of(x); \
0298         } \
0299     /**/
0300 
0301 
0302     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_begin_const(Fullname) \
0303         inline \
0304         boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
0305         BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname const& x) \
0306         { \
0307             return boost::range_detail_microsoft::begin_of(x); \
0308         } \
0309     /**/
0310 
0311 
0312     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end(Fullname) \
0313         inline \
0314         boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
0315         BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname& x) \
0316         { \
0317             return boost::range_detail_microsoft::end_of(x); \
0318         } \
0319     /**/
0320 
0321 
0322     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_end_const(Fullname) \
0323         inline \
0324         boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
0325         BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname const& x) \
0326         { \
0327             return boost::range_detail_microsoft::end_of(x); \
0328         } \
0329     /**/
0330 
0331 
0332     #if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
0333 
0334         #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size(Fullname) \
0335         /**/
0336 
0337     #else
0338 
0339         #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE_size(Fullname) \
0340             inline \
0341             boost::range_detail_microsoft::size_type_of< Fullname >::type \
0342             boost_range_size(Fullname const& x) \
0343             { \
0344                 return boost::range_detail_microsoft::size_of(x); \
0345             } \
0346         /**/
0347 
0348     #endif
0349 
0350 
0351 #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(Tag, NamespaceList, Name, ParamSeqOrCount) \
0352     BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_impl( \
0353         Tag, NamespaceList, Name, \
0354         BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq(ParamSeqOrCount) \
0355     ) \
0356 /**/
0357 
0358     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq(ParamSeqOrCount) \
0359         BOOST_PP_IIF(BOOST_PP_IS_UNARY(ParamSeqOrCount), \
0360             ParamSeqOrCount BOOST_PP_TUPLE_EAT(3), \
0361             BOOST_PP_REPEAT \
0362         )(ParamSeqOrCount, BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq_op, ~) \
0363     /**/
0364 
0365         #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_to_param_seq_op(z, n, _) \
0366             (class) \
0367         /**/
0368 
0369 
0370 #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_impl(Tag, NamespaceList, Name, ParamSeq) \
0371     namespace boost { namespace range_detail_microsoft { \
0372             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_tag( \
0373             Tag, \
0374             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
0375             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
0376         ) \
0377     } } \
0378     \
0379     namespace boost { \
0380         BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_mutable_iterator( \
0381             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
0382             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
0383         ) \
0384         BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_const_iterator( \
0385             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
0386             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
0387         ) \
0388         \
0389         BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size_type( \
0390             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
0391             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
0392         ) \
0393     } \
0394     \
0395     BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_open(NamespaceList) \
0396         BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin( \
0397             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
0398             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
0399         ) \
0400         BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin_const( \
0401             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
0402             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
0403         ) \
0404         BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end( \
0405             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
0406             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
0407         ) \
0408         BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end_const( \
0409             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
0410             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
0411         ) \
0412         BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size( \
0413             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq), \
0414             BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
0415         ) \
0416     BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_close(NamespaceList) \
0417 /**/
0418 
0419 
0420     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params(ParamSeq) \
0421         BOOST_PP_SEQ_FOR_EACH_I(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params_op, ~, ParamSeq) \
0422     /**/
0423 
0424         #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_params_op(r, data, i, elem) \
0425             BOOST_PP_COMMA_IF(i) elem BOOST_PP_CAT(T, i) \
0426         /**/
0427 
0428 
0429     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_fullname(NamespaceList, Name, ParamSeq) \
0430         BOOST_PP_LIST_FOR_EACH(BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_namespace_expand_op, ~, NamespaceList) \
0431         :: Name < BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(ParamSeq), T) > \
0432     /**/
0433 
0434 
0435     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_tag(Tag, Params, Fullname) \
0436         template< Params > \
0437         struct customization_tag< Fullname > : \
0438             customization_tag_of< Tag, Fullname > \
0439         { }; \
0440     /**/
0441 
0442 
0443     // metafunctions
0444     //
0445 
0446     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_mutable_iterator(Params, Fullname) \
0447         template< Params > \
0448         struct BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator< Fullname > : \
0449             range_detail_microsoft::mutable_iterator_of< Fullname > \
0450         { }; \
0451     /**/
0452 
0453 
0454     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_const_iterator(Params, Fullname) \
0455         template< Params > \
0456         struct range_const_iterator< Fullname > : \
0457             range_detail_microsoft::const_iterator_of< Fullname > \
0458         { }; \
0459     /**/
0460 
0461 
0462     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size_type(Params, Fullname) \
0463         template< Params > \
0464         struct range_size< Fullname > : \
0465             range_detail_microsoft::size_type_of< Fullname > \
0466         { }; \
0467     /**/
0468 
0469 
0470     // functions
0471     //
0472 
0473     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin(Params, Fullname) \
0474         template< Params > inline \
0475         typename boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
0476         BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname& x) \
0477         { \
0478             return boost::range_detail_microsoft::begin_of(x); \
0479         } \
0480     /**/
0481 
0482 
0483     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_begin_const(Params, Fullname) \
0484         template< Params > inline \
0485         typename boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
0486         BOOST_RANGE_DETAIL_MICROSOFT_range_begin(Fullname const& x) \
0487         { \
0488             return boost::range_detail_microsoft::begin_of(x); \
0489         } \
0490     /**/
0491 
0492 
0493     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end(Params, Fullname) \
0494         template< Params > inline \
0495         typename boost::range_detail_microsoft::mutable_iterator_of< Fullname >::type \
0496         BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname& x) \
0497         { \
0498             return boost::range_detail_microsoft::end_of(x); \
0499         } \
0500     /**/
0501 
0502 
0503     #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_end_const(Params, Fullname) \
0504         template< Params > inline \
0505         typename boost::range_detail_microsoft::const_iterator_of< Fullname >::type \
0506         BOOST_RANGE_DETAIL_MICROSOFT_range_end(Fullname const& x) \
0507         { \
0508             return boost::range_detail_microsoft::end_of(x); \
0509         } \
0510     /**/
0511 
0512 
0513     #if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
0514 
0515         #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size(Params, Fullname) \
0516         /**/
0517 
0518     #else
0519 
0520         #define BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE_size(Params, Fullname) \
0521             template< Params > inline \
0522             typename boost::range_detail_microsoft::size_type_of< Fullname >::type \
0523             boost_range_size(Fullname const& x) \
0524             { \
0525                 return boost::range_detail_microsoft::size_of(x); \
0526             } \
0527         /**/
0528 
0529     #endif
0530 
0531 
0532 
0533 
0534 // list_iterator and helpers
0535 //
0536 
0537 
0538 #include <boost/assert.hpp>
0539 #include <boost/iterator/iterator_categories.hpp>
0540 #include <boost/iterator/iterator_facade.hpp>
0541 #include <boost/mpl/if.hpp>
0542 #include <boost/type_traits/is_same.hpp>
0543 
0544 
0545 // POSITION's header is undocumented, so is NULL.
0546 //
0547 struct __POSITION; // incomplete, but used as just a pointer.
0548 typedef __POSITION *POSITION;
0549 
0550 
0551 namespace boost { namespace range_detail_microsoft {
0552 
0553 
0554     template<
0555         class ListT,
0556         class Value,
0557         class Reference,
0558         class Traversal
0559     >
0560     struct list_iterator;
0561 
0562 
0563     template<
0564         class ListT,
0565         class Value,
0566         class Reference,
0567         class Traversal
0568     >
0569     struct list_iterator_super
0570     {
0571         typedef typename mpl::if_< is_same<use_default, Reference>,
0572             Value&,
0573             Reference
0574         >::type ref_t;
0575 
0576         typedef typename mpl::if_< is_same<use_default, Traversal>,
0577             bidirectional_traversal_tag,
0578             Traversal
0579         >::type trv_t;
0580 
0581         typedef iterator_facade<
0582             list_iterator<ListT, Value, Reference, Traversal>,
0583             Value,
0584             trv_t,
0585             ref_t
0586         > type;
0587     };
0588 
0589 
0590     template<
0591         class ListT,
0592         class Value,
0593         class Reference = use_default,
0594         class Traversal = use_default
0595     >
0596     struct list_iterator :
0597         list_iterator_super<ListT, Value, Reference, Traversal>::type
0598     {
0599     private:
0600         typedef list_iterator self_t;
0601         typedef typename list_iterator_super<ListT, Value, Reference, Traversal>::type super_t;
0602         typedef typename super_t::reference ref_t;
0603 
0604     public:
0605         explicit list_iterator()
0606         { }
0607 
0608         explicit list_iterator(ListT& lst, POSITION pos) :
0609             m_plst(boost::addressof(lst)), m_pos(pos)
0610         { }
0611 
0612     template< class, class, class, class > friend struct list_iterator;
0613         template< class ListT_, class Value_, class Reference_, class Traversal_>
0614         list_iterator(list_iterator<ListT_, Value_, Reference_, Traversal_> const& other) :
0615             m_plst(other.m_plst), m_pos(other.m_pos)
0616         { }
0617 
0618     private:
0619         ListT *m_plst;
0620         POSITION m_pos;
0621 
0622     friend class iterator_core_access;
0623         ref_t dereference() const
0624         {
0625             BOOST_ASSERT(m_pos != 0 && "out of range");
0626             return m_plst->GetAt(m_pos);
0627         }
0628 
0629         // A    B    C    D    x
0630         // Head           Tail NULL(0)
0631         //
0632         void increment()
0633         {
0634             BOOST_ASSERT(m_pos != 0 && "out of range");
0635             m_plst->GetNext(m_pos);
0636         }
0637 
0638         void decrement()
0639         {
0640             if (m_pos == 0) {
0641                 m_pos = m_plst->GetTailPosition();
0642                 return;
0643             }
0644 
0645             m_plst->GetPrev(m_pos);
0646         }
0647 
0648         bool equal(self_t const& other) const
0649         {
0650             BOOST_ASSERT(m_plst == other.m_plst && "iterators incompatible");
0651             return m_pos == other.m_pos;
0652         }
0653     };
0654 
0655 
0656     // customization helpers
0657     //
0658 
0659     struct array_functions
0660     {
0661         template< class Iterator, class X >
0662         Iterator begin(X& x)
0663         {
0664             return x.GetData();
0665         }
0666 
0667         template< class Iterator, class X >
0668         Iterator end(X& x)
0669         {
0670             return begin<Iterator>(x) + x.GetSize();
0671         }
0672     };
0673 
0674 
0675     struct list_functions
0676     {
0677         template< class Iterator, class X >
0678         Iterator begin(X& x)
0679         {
0680             return Iterator(x, x.GetHeadPosition());
0681         }
0682 
0683         template< class Iterator, class X >
0684         Iterator end(X& x)
0685         {
0686             return Iterator(x, POSITION(0));
0687         }
0688     };
0689 
0690 
0691 } } // namespace boost::range_detail_microsoft
0692 
0693 
0694 
0695 
0696 // test
0697 //
0698 
0699 
0700 #if defined(BOOST_RANGE_DETAIL_MICROSOFT_TEST)
0701 
0702 
0703 #include <algorithm>
0704 #include <iterator>
0705 #include <vector>
0706 #include <boost/concept_check.hpp>
0707 #include <boost/next_prior.hpp>
0708 #include <boost/range/begin.hpp>
0709 #include <boost/range/concepts.hpp>
0710 #include <boost/range/const_iterator.hpp>
0711 #include <boost/range/difference_type.hpp>
0712 #include <boost/range/distance.hpp>
0713 #include <boost/range/empty.hpp>
0714 #include <boost/range/iterator_range.hpp>
0715 #include <boost/range/mutable_iterator.hpp>
0716 #include <boost/range/rbegin.hpp>
0717 #include <boost/range/rend.hpp>
0718 #include <boost/range/value_type.hpp>
0719 #include <boost/type_traits/is_same.hpp>
0720 
0721 
0722 namespace boost { namespace range_detail_microsoft {
0723 
0724 
0725     template< class Range1, class Range2 >
0726     bool test_equals(Range1 const& rng1, Range2 const& rng2)
0727     {
0728         return
0729             boost::distance(rng1) == boost::distance(rng2) &&
0730             std::equal(boost::begin(rng1), boost::end(rng1), boost::begin(rng2))
0731         ;
0732     }
0733 
0734 
0735     template< class AssocContainer, class PairT >
0736     bool test_find_key_and_mapped(AssocContainer const& ac, PairT const& pa)
0737     {
0738         typedef typename boost::range_const_iterator<AssocContainer>::type iter_t;
0739         for (iter_t it = boost::const_begin(ac), last = boost::const_end(ac); it != last; ++it) {
0740             if (it->first == pa.first && it->second == pa.second)
0741                 return true;
0742         }
0743 
0744         return false;
0745     }
0746 
0747 
0748     // test functions
0749     //
0750 
0751     template< class Range >
0752     bool test_emptiness(Range& )
0753     {
0754         bool result = true;
0755 
0756         Range emptyRng;
0757         result = result && boost::empty(emptyRng);
0758 
0759         return result;
0760     }
0761 
0762 
0763     template< class Range >
0764     bool test_trivial(Range& rng)
0765     {
0766         bool result = true;
0767 
0768         // convertibility check
0769         typedef typename range_const_iterator<Range>::type citer_t;
0770         citer_t cit = boost::begin(rng);
0771         (void)cit; // unused
0772 
0773         // mutability check
0774         typedef typename range_value<Range>::type val_t;
0775         val_t v = *boost::begin(rng);
0776         *boost::begin(rng) = v;
0777         result = result && *boost::begin(rng) == v;
0778 
0779         return result;
0780     }
0781 
0782 
0783     template< class Range >
0784     bool test_forward(Range& rng)
0785     {
0786         boost::function_requires< ForwardRangeConcept<Range> >();
0787 
0788         bool result = (test_trivial)(rng);
0789 
0790         typedef typename range_value<Range>::type val_t;
0791 
0792         std::vector<val_t> saved;
0793         std::copy(boost::begin(rng), boost::end(rng), std::back_inserter(saved));
0794         std::rotate(boost::begin(saved), boost::next(boost::begin(saved)), boost::end(saved));
0795 
0796         std::rotate(boost::begin(rng), boost::next(boost::begin(rng)), boost::end(rng));
0797 
0798         return result && (test_equals)(saved, rng);
0799     };
0800 
0801 
0802     template< class Range >
0803     bool test_bidirectional(Range& rng)
0804     {
0805         boost::function_requires< BidirectionalRangeConcept<Range> >();
0806 
0807         bool result = (test_forward)(rng);
0808 
0809         typedef typename range_value<Range>::type val_t;
0810 
0811         std::vector<val_t> saved;
0812         std::copy(boost::begin(rng), boost::end(rng), std::back_inserter(saved));
0813 
0814         result = result && (test_equals)(
0815             boost::make_iterator_range(boost::rbegin(saved), boost::rend(saved)),
0816             boost::make_iterator_range(boost::rbegin(rng), boost::rend(rng))
0817         );
0818 
0819         return result;
0820     }
0821 
0822 
0823     template< class Range >
0824     bool test_random_access(Range& rng)
0825     {
0826         boost::function_requires< RandomAccessRangeConcept<Range> >();
0827 
0828         bool result = (test_bidirectional)(rng);
0829 
0830         typedef typename range_value<Range>::type val_t;
0831 
0832         std::vector<val_t> saved;
0833         std::copy(boost::begin(rng), boost::end(rng), std::back_inserter(saved));
0834         std::sort(boost::begin(saved), boost::end(saved));
0835 
0836         std::random_shuffle(boost::begin(rng), boost::end(rng));
0837         std::sort(boost::begin(rng), boost::end(rng));
0838         result = result && (test_equals)(rng, saved);
0839 
0840         std::random_shuffle(boost::begin(rng), boost::end(rng));
0841         std::stable_sort(boost::begin(rng), boost::end(rng));
0842         result = result && (test_equals)(rng, saved);
0843 
0844         std::random_shuffle(boost::begin(rng), boost::end(rng));
0845         std::partial_sort(boost::begin(rng), boost::end(rng), boost::end(rng));
0846         result = result && (test_equals)(rng, saved);
0847 
0848         return result;
0849     }
0850 
0851 
0852     // initializer
0853     //
0854 
0855     template< class ArrayT, class SampleRange >
0856     bool test_init_array(ArrayT& arr, SampleRange const& sample)
0857     {
0858         typedef typename range_const_iterator<SampleRange>::type iter_t;
0859         typedef typename range_value<SampleRange>::type val_t;
0860 
0861         for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
0862             val_t v = *it; // works around ATL3 CSimpleArray
0863             arr.Add(v);
0864         }
0865 
0866         return (test_equals)(arr, sample);
0867     }
0868 
0869 
0870     template< class ListT, class SampleRange >
0871     bool test_init_list(ListT& lst, SampleRange const& sample)
0872     {
0873         typedef typename range_const_iterator<SampleRange>::type iter_t;
0874 
0875         for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
0876             lst.AddTail(*it);
0877         }
0878 
0879         return (test_equals)(lst, sample);
0880     }
0881 
0882 
0883     template< class StringT, class SampleRange >
0884     bool test_init_string(StringT& str, SampleRange const& sample)
0885     {
0886         typedef typename range_const_iterator<SampleRange>::type iter_t;
0887         typedef typename range_value<SampleRange>::type val_t;
0888 
0889         for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
0890             str += *it;
0891         }
0892 
0893         return (test_equals)(str, sample);
0894     }
0895 
0896 
0897     template< class MapT, class SampleMap >
0898     bool test_init_map(MapT& map, SampleMap const& sample)
0899     {
0900         typedef typename range_const_iterator<SampleMap>::type iter_t;
0901 
0902         for (iter_t it = boost::const_begin(sample), last = boost::const_end(sample); it != last; ++it) {
0903             map.SetAt(it->first, it->second);
0904         }
0905 
0906         return boost::distance(map) == boost::distance(sample);
0907     }
0908 
0909 
0910     // metafunction test
0911     //
0912 
0913     template< class Range, class Iter >
0914     struct test_mutable_iter :
0915         boost::is_same< typename boost::BOOST_RANGE_DETAIL_MICROSOFT_range_mutable_iterator<Range>::type, Iter >
0916     { };
0917 
0918 
0919     template< class Range, class Iter >
0920     struct test_const_iter :
0921         boost::is_same< typename boost::range_const_iterator<Range>::type, Iter >
0922     { };
0923 
0924 
0925 } } // namespace boost::range_detail_microsoft
0926 
0927 
0928 #endif // defined(BOOST_RANGE_DETAIL_MICROSOFT_TEST)
0929 
0930 
0931 
0932 #endif