MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / join_if

Function join_if

include/win/boost/algorithm/string/join.hpp:95–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93 */
94 template< typename SequenceSequenceT, typename Range1T, typename PredicateT>
95 inline typename range_value<SequenceSequenceT>::type
96 join_if(
97 const SequenceSequenceT& Input,
98 const Range1T& Separator,
99 PredicateT Pred)
100 {
101 // Define working types
102 typedef typename range_value<SequenceSequenceT>::type ResultT;
103 typedef typename range_const_iterator<SequenceSequenceT>::type InputIteratorT;
104
105 // Parse input
106 InputIteratorT itBegin=::boost::begin(Input);
107 InputIteratorT itEnd=::boost::end(Input);
108
109 // Construct container to hold the result
110 ResultT Result;
111
112 // Roll to the first element that will be added
113 while(itBegin!=itEnd && !Pred(*itBegin)) ++itBegin;
114 // Add this element
115 if(itBegin!=itEnd)
116 {
117 detail::insert(Result, ::boost::end(Result), *itBegin);
118 ++itBegin;
119 }
120
121 for(;itBegin!=itEnd; ++itBegin)
122 {
123 if(Pred(*itBegin))
124 {
125 // Add separator
126 detail::insert(Result, ::boost::end(Result), ::boost::as_literal(Separator));
127 // Add element
128 detail::insert(Result, ::boost::end(Result), *itBegin);
129 }
130 }
131
132 return Result;
133 }
134
135 } // namespace algorithm
136

Callers

nothing calls this directly

Calls 4

beginFunction · 0.50
endFunction · 0.50
insertFunction · 0.50
as_literalFunction · 0.50

Tested by

no test coverage detected