Skip to content

Commit e6b2bd8

Browse files
committed
Use variadic template expansion in min category deduction in zip_iterator.
This results in marginally faster compile times in modern code bases where tuples are variadic.
1 parent 4c02a90 commit e6b2bd8

File tree

1 file changed

+16
-27
lines changed

1 file changed

+16
-27
lines changed

include/boost/iterator/zip_iterator.hpp

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,6 @@ struct is_trailing_null_type< tuples::null_type > : std::true_type {};
107107
template< >
108108
struct is_trailing_null_type< fusion::void_ > : std::true_type {};
109109

110-
// The trait checks if the tail is either an empty type list or begins with a "null" type, which indicates that the rest
111-
// of the types in the tail are unused
112-
template< typename... Tail >
113-
struct is_tail_empty;
114-
template< >
115-
struct is_tail_empty< > : std::true_type {};
116-
template< typename Front, typename... Tail >
117-
struct is_tail_empty< Front, Tail... > : detail::is_trailing_null_type< Front > {};
118-
119110
// Metafunction to obtain the type of the tuple whose element types
120111
// are the reference types of an iterator tuple.
121112
template< typename IteratorTuple >
@@ -161,30 +152,28 @@ struct minimum_traversal_category_in_iterator_list;
161152
template< typename IteratorList >
162153
using minimum_traversal_category_in_iterator_list_t = typename minimum_traversal_category_in_iterator_list< IteratorList >::type;
163154

164-
template< typename FrontTraversal, typename Tail >
165-
using minimum_traversal_category_in_tail_t = min_category_t<
166-
FrontTraversal,
167-
minimum_traversal_category_in_iterator_list_t< Tail >
168-
>;
169-
170-
template< template< typename... > class List, typename Front, typename... Tail >
171-
struct minimum_traversal_category_in_iterator_list< List< Front, Tail... > >
155+
template< template< typename... > class List, typename... Iterators >
156+
struct minimum_traversal_category_in_iterator_list< List< Iterators... > >
172157
{
173-
using front_traversal = pure_iterator_traversal_t< Front >;
174-
175158
// Note: non-variadic Boost.Tuple and Boost.Fusion need special handling
176159
// to avoid instantiating iterator traits on the trailing "null" types.
177-
// Note 2: we rename the List to mp_list in the process of iteration to
178-
// avoid specifying one template parameter to std::pair, if List is std::pair.
179-
using type = mp11::mp_eval_if<
180-
detail::is_tail_empty< Tail... >,
181-
front_traversal,
182-
minimum_traversal_category_in_tail_t,
183-
front_traversal,
184-
mp11::mp_list< Tail... >
160+
// For such types just use random_access_traversal_tag, which will not
161+
// affect the result of min_category.
162+
using type = min_category_t<
163+
mp11::mp_eval_if<
164+
detail::is_trailing_null_type< Iterators >,
165+
random_access_traversal_tag,
166+
pure_iterator_traversal_t, Iterators
167+
>...
185168
>;
186169
};
187170

171+
template< typename FrontTraversal, typename Tail >
172+
using minimum_traversal_category_in_tail_t = min_category_t<
173+
FrontTraversal,
174+
minimum_traversal_category_in_iterator_list_t< Tail >
175+
>;
176+
188177
template< typename Front, typename Tail >
189178
struct minimum_traversal_category_in_iterator_list< tuples::cons< Front, Tail > >
190179
{

0 commit comments

Comments
 (0)