1 // ==========================================================================
2 //                 SeqAn - The Library for Sequence Analysis
3 // ==========================================================================
4 // Copyright (c) 2006-2018, Knut Reinert, FU Berlin
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are met:
9 //
10 //     * Redistributions of source code must retain the above copyright
11 //       notice, this list of conditions and the following disclaimer.
12 //     * Redistributions in binary form must reproduce the above copyright
13 //       notice, this list of conditions and the following disclaimer in the
14 //       documentation and/or other materials provided with the distribution.
15 //     * Neither the name of Knut Reinert or the FU Berlin nor the names of
16 //       its contributors may be used to endorse or promote products derived
17 //       from this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
23 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
29 // DAMAGE.
30 //
31 // ==========================================================================
32 // Author: Hannes Hauswedell <hannes.hauswedell@fu-berlin.de>
33 // ==========================================================================
34 // Adaptions for STL containers to SeqAn sequences.
35 // ==========================================================================
36 
37 #ifndef SEQAN_SEQUENCE_ADAPT_STL_CONTAINER_H_
38 #define SEQAN_SEQUENCE_ADAPT_STL_CONTAINER_H_
39 
40 namespace seqan {
41 
42 // ===========================================================================
43 // Enums, Tags, Classes, Specializations
44 // ===========================================================================
45 
46 // ===========================================================================
47 // Concepts
48 // ===========================================================================
49 
50 template <typename TChar, typename TAlloc>
51 SEQAN_CONCEPT_IMPL((std::vector<TChar, TAlloc>), (StlContainerConcept));
52 
53 template <typename TChar, typename TAlloc>
54 SEQAN_CONCEPT_IMPL((std::vector<TChar, TAlloc> const), (StlContainerConcept));
55 
56 template <typename TChar, typename TAlloc>
57 SEQAN_CONCEPT_IMPL((std::deque<TChar, TAlloc>), (StlContainerConcept));
58 
59 template <typename TChar, typename TAlloc>
60 SEQAN_CONCEPT_IMPL((std::deque<TChar, TAlloc> const), (StlContainerConcept));
61 
62 template <typename TChar, typename TAlloc>
63 SEQAN_CONCEPT_IMPL((std::list<TChar, TAlloc>), (StlContainerConcept));
64 
65 template <typename TChar, typename TAlloc>
66 SEQAN_CONCEPT_IMPL((std::list<TChar, TAlloc> const), (StlContainerConcept));
67 
68 template<typename TChar, typename TTraits, typename TAlloc>
69 SEQAN_CONCEPT_IMPL((std::basic_string<TChar, TTraits, TAlloc>), (StlContainerConcept));
70 
71 template<typename TChar, typename TTraits, typename TAlloc>
72 SEQAN_CONCEPT_IMPL((std::basic_string<TChar, TTraits, TAlloc> const), (StlContainerConcept));
73 
74 template <typename TChar, typename TAlloc>
75 SEQAN_CONCEPT_IMPL((std::forward_list<TChar, TAlloc>), (StlContainerConcept));
76 
77 template <typename TChar, typename TAlloc>
78 SEQAN_CONCEPT_IMPL((std::forward_list<TChar, TAlloc> const), (StlContainerConcept));
79 
80 template <typename TChar, std::size_t N>
81 SEQAN_CONCEPT_IMPL((std::array<TChar, N>), (StlContainerConcept));
82 
83 template <typename TChar, std::size_t N>
84 SEQAN_CONCEPT_IMPL((std::array<TChar, N> const), (StlContainerConcept));
85 
86 /* NOTE(h-2) on ConceptChecking and universal references
87  *
88  * When type deduction takes place before && then && can act as both && or &
89  * [https://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers]
90  *
91  * This has the effect that in
92  *      foobar(T &&)
93  * T actually can be "int &". Consequently the above becomes "int & &&" which
94  * collapses to "int &". The important thing is that in
95  *      template<typename EnableIf<Is<SuperConcept<T> >
96  * this will result in the ConceptCheck always failing (because the Concept is
97  * not defined for reference types).
98  *
99  * So in the following you will see a RemoveReference< > around the type
100  * whenever the function takes a && argument AND it shall act as univeral
101  * reference (e.g. length()). But in some cases it shall not (because there is a
102  * different overload for the l-value-reference arg) and it is  intentionally
103  * omitted, e.g. value().
104 
105  */
106 
107 // ===========================================================================
108 // Metafunctions
109 // ===========================================================================
110 
111 // ----------------------------------------------------------------------------
112 // Metafunctions that are the same for all STL containers
113 // ----------------------------------------------------------------------------
114 
115 #define COMMA ,
116 
117 #define SUPERMACRO__(CONT, TMPL) \
118 template <TMPL> \
119 struct Value<CONT> \
120 { \
121     typedef typename CONT::value_type Type; \
122 };\
123 template <TMPL> \
124 struct Value<CONT const> \
125 { \
126     typedef typename CONT::value_type Type; \
127 };\
128 template <TMPL> \
129 struct Reference<CONT> \
130 { \
131     typedef typename CONT::reference Type; \
132 };\
133 template <TMPL> \
134 struct Reference<CONT const> \
135 { \
136     typedef typename CONT::const_reference Type; \
137 };\
138 template <TMPL> \
139 struct GetValue<CONT> \
140 { \
141     typedef typename CONT::const_reference Type; \
142 };\
143 template <TMPL> \
144 struct GetValue<CONT const> \
145 { \
146     typedef typename CONT::const_reference Type; \
147 };\
148 template <TMPL> \
149 struct Position<CONT> \
150 { \
151     typedef typename CONT::size_type Type; \
152 };\
153 template <TMPL> \
154 struct Position<CONT const> \
155 { \
156     typedef typename CONT::size_type Type; \
157 };\
158 template <TMPL> \
159 struct Size<CONT> \
160 { \
161     typedef typename CONT::size_type Type; \
162 };\
163 template <TMPL> \
164 struct Size<CONT const> \
165 { \
166     typedef typename CONT::size_type Type; \
167 };\
168 template <TMPL> \
169 struct Iterator<CONT, Standard> \
170 { \
171     typedef Iter<CONT, StdIteratorAdaptor> Type;\
172 };\
173 template <TMPL> \
174 struct Iterator<CONT const, Standard> \
175 { \
176     typedef Iter<CONT const, StdIteratorAdaptor> Type;\
177 };\
178 template <TMPL> \
179 struct Iterator<CONT, Rooted> \
180 { \
181     typedef Iter<CONT, AdaptorIterator<Iter<CONT, StdIteratorAdaptor> > > Type;\
182 }; \
183 template <TMPL> \
184 struct Iterator<CONT const, Rooted> \
185 { \
186     typedef Iter<CONT const, AdaptorIterator<Iter<CONT const, StdIteratorAdaptor> > > Type;\
187 };
188 
189 SUPERMACRO__(std::vector<TChar COMMA TAlloc>,      typename TChar COMMA typename TAlloc)
190 SUPERMACRO__(std::deque<TChar COMMA TAlloc>,       typename TChar COMMA typename TAlloc)
191 SUPERMACRO__(std::list<TChar COMMA TAlloc>,        typename TChar COMMA typename TAlloc)
192 SUPERMACRO__(std::forward_list<TChar COMMA TAlloc>,typename TChar COMMA typename TAlloc)
193 SUPERMACRO__(std::array<TChar COMMA N>,            typename TChar COMMA std::size_t N)
194 SUPERMACRO__(std::basic_string<TChar COMMA TTraits COMMA TAlloc>, typename TChar COMMA typename TTraits COMMA typename TAlloc)
195 
196 // ----------------------------------------------------------------------------
197 // Mfn IsContiguous (default is False)
198 // ----------------------------------------------------------------------------
199 
200 template <typename TChar, typename TAlloc>
201 struct IsContiguous<std::vector<TChar, TAlloc> > :
202     public True
203 {};
204 
205 template <typename TChar, typename TAlloc>
206 struct IsContiguous<std::vector<TChar, TAlloc> const> :
207     public True
208 {};
209 
210 template <typename TChar, typename TTraits, typename TAlloc>
211 struct IsContiguous<std::basic_string<TChar, TTraits, TAlloc> > :
212     public True
213 {};
214 
215 template <typename TChar, typename TTraits, typename TAlloc>
216 struct IsContiguous<std::basic_string<TChar, TTraits, TAlloc> const> :
217     public True
218 {};
219 
220 template <typename TChar, size_t N>
221 struct IsContiguous<std::array<TChar, N> > :
222     public True
223 {};
224 
225 template <typename TChar, size_t N>
226 struct IsContiguous<std::array<TChar, N> const> :
227     public True
228 {};
229 
230 // ----------------------------------------------------------------------------
231 // Mfn HasSubscriptOperator (different for e.g. std::deque)
232 // ----------------------------------------------------------------------------
233 
234 template <typename TChar, typename TAlloc>
235 struct HasSubscriptOperator<std::deque<TChar, TAlloc> > :
236     public True
237 {};
238 
239 template <typename TChar, typename TAlloc>
240 struct HasSubscriptOperator<std::deque<TChar, TAlloc> const> :
241     public True
242 {};
243 
244 // ----------------------------------------------------------------------------
245 // Mfn IsSequence
246 // ----------------------------------------------------------------------------
247 
248 //NOTE(h-2): shouldnt we be using Is<StringConcept> or IsContiguous<> or ...?
249 
250 template <typename TChar, typename TAlloc>
251 struct IsSequence<std::vector<TChar, TAlloc> > : True {};
252 
253 template <typename TChar, typename TAlloc>
254 struct IsSequence<std::deque<TChar, TAlloc> > : True {};
255 
256 template <typename TChar, typename TAlloc>
257 struct IsSequence<std::list<TChar, TAlloc> > : True {};
258 
259 template <typename TChar, typename TAlloc>
260 struct IsSequence<std::forward_list<TChar, TAlloc> > : True {};
261 
262 //NOTE(h-2): array isn't by SeqAn definition, right?
263 
264 template <typename TChar, typename TCharTraits, typename TAlloc>
265 struct IsSequence<std::basic_string<TChar, TCharTraits, TAlloc> > : True {};
266 
267 // ----------------------------------------------------------------------------
268 // Mfn FixedSize_ (private)
269 // ----------------------------------------------------------------------------
270 
271 template <typename TContainer>
272 struct FixedSize_ : public False {};
273 
274 template <typename TChar, size_t N>
275 struct FixedSize_<std::array<TChar, N> > : public True {};
276 
277 // ===========================================================================
278 // Functions
279 // ===========================================================================
280 
281 // ----------------------------------------------------------------------------
282 // Function getObjectId
283 // ----------------------------------------------------------------------------
284 
285 template <typename TContainer>
286 inline SEQAN_FUNC_ENABLE_IF(Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >, void const *)
287 getObjectId(TContainer && me)
288 {
289     if (me.empty())
290         return NULL;
291     else
292         return (& *(me.end() - 1)) + 1;
293 }
294 
295 // ----------------------------------------------------------------------------
296 // Function begin (standard)
297 // ----------------------------------------------------------------------------
298 
299 template <typename TContainer>
300 inline SEQAN_FUNC_ENABLE_IF(Is<StlContainerConcept<TContainer> >, typename Iterator<TContainer, Standard>::Type)
301 begin(TContainer & me, Standard const &)
302 {
303     return me.begin();
304 }
305 
306 template <typename TContainer>
307 inline SEQAN_FUNC_ENABLE_IF(Is<StlContainerConcept<TContainer> >, typename Iterator<TContainer const, Standard>::Type)
308 begin(TContainer const & me, Standard const &)
309 {
310     return me.begin();
311 }
312 
313 // ----------------------------------------------------------------------------
314 // Function begin (rooted)
315 // ----------------------------------------------------------------------------
316 
317 template <typename TContainer>
318 inline SEQAN_FUNC_ENABLE_IF(Is<StlContainerConcept<TContainer> >, typename Iterator<TContainer, Rooted>::Type)
319 begin(TContainer & me, Rooted const &)
320 {
321     return _beginDefault(me, Rooted());
322 }
323 
324 template <typename TContainer>
325 inline SEQAN_FUNC_ENABLE_IF(Is<StlContainerConcept<TContainer> >, typename Iterator<TContainer const, Rooted>::Type)
326 begin(TContainer const & me, Rooted const &)
327 {
328     return _beginDefault(me, Rooted());
329 }
330 
331 // ----------------------------------------------------------------------------
332 // Function end (standard)
333 // ----------------------------------------------------------------------------
334 
335 template <typename TContainer>
336 inline SEQAN_FUNC_ENABLE_IF(Is<StlContainerConcept<TContainer> >, typename Iterator<TContainer, Standard>::Type)
337 end(TContainer & me, Standard const &)
338 {
339     return me.end();
340 }
341 
342 template <typename TContainer>
343 inline SEQAN_FUNC_ENABLE_IF(Is<StlContainerConcept<TContainer> >, typename Iterator<TContainer const, Standard>::Type)
344 end(TContainer const & me, Standard const &)
345 {
346     return me.end();
347 }
348 
349 // ----------------------------------------------------------------------------
350 // Function end (rooted)
351 // ----------------------------------------------------------------------------
352 
353 template <typename TContainer>
354 inline SEQAN_FUNC_ENABLE_IF(Is<StlContainerConcept<TContainer> >, typename Iterator<TContainer, Rooted>::Type)
355 end(TContainer & me, Rooted const &)
356 {
357     return _endDefault(me, Rooted());
358 }
359 
360 template <typename TContainer>
361 inline SEQAN_FUNC_ENABLE_IF(Is<StlContainerConcept<TContainer> >, typename Iterator<TContainer const, Rooted>::Type)
362 end(TContainer const & me, Rooted const &)
363 {
364     return _endDefault(me, Rooted());
365 }
366 
367 // ----------------------------------------------------------------------------
368 // Function _iterStl (like seqan's iter() but for stl-iterators)
369 // ----------------------------------------------------------------------------
370 
371 template <typename TContainer,
372           typename TPos>
373 inline typename TContainer::iterator
374 _iterStl(TContainer & me,
375          TPos const pos)
376 {
377     SEQAN_ASSERT_LEQ_MSG(pos,
378                          static_cast<TPos>(length(me)),
379                          "Trying to get an iterator behind a container through _iterStl().");
380     return std::next(me.begin(), pos);
381 }
382 
383 template <typename TContainer,
384           typename TPos>
385 inline typename TContainer::const_iterator
386 _iterStl(TContainer const & me,
387          TPos const pos)
388 {
389     SEQAN_ASSERT_LEQ_MSG(pos,
390                          static_cast<TPos>(length(me)),
391                          "Trying to get an iterator behind a container through _iterStl().");
392     return std::next(me.begin(), pos);
393 }
394 
395 // ----------------------------------------------------------------------------
396 // Function iter (Standard) (only overloaded for non-contiguous)
397 // ----------------------------------------------------------------------------
398 
399 template <typename TChar, typename TAlloc, typename TPos>
400 inline typename Iterator<std::list<TChar, TAlloc>, Standard>::Type
401 iter(std::list<TChar, TAlloc> & me,
402      TPos const pos,
403      Standard const &)
404 {
405     return _iterStl(me, pos);
406 }
407 
408 template <typename TChar, typename TAlloc, typename TPos>
409 inline typename Iterator<std::list<TChar, TAlloc> const, Standard>::Type
410 iter(std::list<TChar, TAlloc> const & me,
411      TPos const pos,
412      Standard const &)
413 {
414     return _iterStl(me, pos);
415 }
416 
417 template <typename TChar, typename TAlloc, typename TPos>
418 inline typename Iterator<std::forward_list<TChar, TAlloc>, Standard const>::Type
419 iter(std::forward_list<TChar, TAlloc> & me,
420      TPos const pos,
421      Standard const &)
422 {
423     return _iterStl(me, pos);
424 }
425 
426 template <typename TChar, typename TAlloc, typename TPos>
427 inline typename Iterator<std::forward_list<TChar, TAlloc> const, Standard>::Type
428 iter(std::forward_list<TChar, TAlloc> const & me,
429      TPos const pos,
430      Standard const &)
431 {
432     return _iterStl(me, pos);
433 }
434 
435 // ----------------------------------------------------------------------------
436 // Function iter (Rooted) (only overloaded for non-contiguous)
437 // ----------------------------------------------------------------------------
438 
439 template <typename TChar, typename TAlloc, typename TPos>
440 inline typename Iterator<std::list<TChar, TAlloc>, Rooted>::Type
441 iter(std::list<TChar, TAlloc> & me,
442      TPos const pos,
443      Rooted const &)
444 {
445     typedef typename Iterator<std::list<TChar, TAlloc>, Rooted>::Type TIterator;
446     return TIterator(me, iter(me, pos, Standard()));
447 }
448 
449 template <typename TChar, typename TAlloc, typename TPos>
450 inline typename Iterator<std::list<TChar, TAlloc> const, Rooted>::Type
451 iter(std::list<TChar, TAlloc> const & me,
452      TPos const pos,
453      Rooted const &)
454 {
455     typedef typename Iterator<std::list<TChar, TAlloc> const, Rooted>::Type TIterator;
456     return TIterator(me, iter(me, pos, Standard()));
457 }
458 
459 template <typename TChar, typename TAlloc, typename TPos>
460 inline typename Iterator<std::forward_list<TChar, TAlloc>, Rooted>::Type
461 iter(std::forward_list<TChar, TAlloc> & me,
462      TPos const pos,
463      Rooted const &)
464 {
465     typedef typename Iterator<std::forward_list<TChar, TAlloc>, Rooted>::Type TIterator;
466     return TIterator(me, iter(me, pos, Standard()));
467 }
468 
469 template <typename TChar, typename TAlloc, typename TPos>
470 inline typename Iterator<std::forward_list<TChar, TAlloc> const, Rooted>::Type
471 iter(std::forward_list<TChar, TAlloc> const & me,
472      TPos const pos,
473      Rooted const &)
474 {
475     typedef typename Iterator<std::forward_list<TChar, TAlloc> const, Rooted>::Type TIterator;
476     return TIterator(me, iter(me, pos, Standard()));
477 }
478 
479 // ----------------------------------------------------------------------------
480 // Function length
481 // ----------------------------------------------------------------------------
482 
483 template <typename TContainer>
484 inline SEQAN_FUNC_ENABLE_IF(Is<StlContainerConcept<TContainer> >, typename Size<TContainer>::Type)
485 length(TContainer const & me)
486 {
487     return me.size();
488 }
489 
490 template <typename TChar, typename TAlloc>
491 inline typename Size<std::forward_list<TChar, TAlloc> >::Type
492 length(std::forward_list<TChar, TAlloc> const & me)
493 {
494     typename Size<std::forward_list<TChar, TAlloc> >::Type l = 0;
495 
496     for (auto it = me.begin(), itEnd = me.end(); it != itEnd; ++it, ++l);
497 
498     return l;
499 }
500 
501 template <typename TChar, std::size_t N>
502 constexpr std::size_t
503 length(std::array<TChar, N> const & me)
504 {
505     return me.size();
506 }
507 
508 // ----------------------------------------------------------------------------
509 // Function capacity
510 // ----------------------------------------------------------------------------
511 
512 template <typename TChar, typename TAlloc>
513 inline typename Size<std::vector<TChar, TAlloc> >::Type
514 capacity(std::vector<TChar, TAlloc> const & me)
515 {
516     return me.capacity();
517 }
518 
519 template <typename TChar, typename TTraits, typename TAlloc>
520 inline typename Size<std::basic_string<TChar, TTraits, TAlloc> >::Type
521 capacity(std::basic_string<TChar, TTraits, TAlloc> const & me)
522 {
523     return me.capacity();
524 }
525 
526 template <typename TChar, std::size_t N>
527 constexpr std::size_t
528 capacity(std::array<TChar, N> const & me)
529 {
530     return me.size();
531 }
532 
533 // for other types the default overload to length holds
534 
535 // ----------------------------------------------------------------------------
536 // Function empty
537 // ----------------------------------------------------------------------------
538 
539 // VC2015 implements some C++17 functions which would collide for
540 // applications that do using namespace std
541 // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4280.pdf
542 // Disable those functions for C++17 and upwards (pre-C++17 defines __cplusplus as <=201402L).
543 #if !(defined(STDLIB_VS) || __cplusplus > 201402L)
544 template <typename TContainer>
545 inline SEQAN_FUNC_ENABLE_IF(Is<StlContainerConcept<TContainer> >, bool)
546 empty(TContainer const & me)
547 {
548     return me.empty();
549 }
550 
551 template <typename TChar, std::size_t N>
552 constexpr bool
553 empty(std::array<TChar, N> const & me)
554 {
555     return me.empty();
556 }
557 #endif
558 
559 // ----------------------------------------------------------------------------
560 // Function reserve
561 // ----------------------------------------------------------------------------
562 
563 template <typename TChar, typename TAlloc, typename TSize, typename TExpand>
564 inline typename Size<std::vector<TChar, TAlloc> >::Type
565 reserve(std::vector<TChar, TAlloc> & me,
566         TSize const s,
567         Tag<TExpand> const &)
568 {
569     me.reserve(s);
570     return capacity(me);
571 }
572 
573 template <typename TChar, typename TTraits, typename TAlloc, typename TSize, typename TExpand>
574 inline typename Size<std::basic_string<TChar, TTraits, TAlloc> >::Type
575 reserve(std::basic_string<TChar, TTraits, TAlloc> & me,
576         TSize const s,
577         Tag<TExpand> const &)
578 {
579     me.reserve(s);
580     return capacity(me);
581 }
582 
583 template <typename TChar, typename TAlloc, typename TSize, typename TExpand>
584 inline typename Size<std::vector<TChar, TAlloc> >::Type
585 reserve(std::vector<TChar, TAlloc> && me,
586         TSize const s,
587         Tag<TExpand> const &)
588 {
589     me.reserve(s);
590     return capacity(me);
591 }
592 
593 template <typename TChar, typename TTraits, typename TAlloc, typename TSize, typename TExpand>
594 inline typename Size<std::basic_string<TChar, TTraits, TAlloc> >::Type
595 reserve(std::basic_string<TChar, TTraits, TAlloc> && me,
596         TSize const s,
597         Tag<TExpand> const &)
598 {
599     me.reserve(s);
600     return capacity(me);
601 }
602 
603 // for other types the default overload holds
604 
605 // ----------------------------------------------------------------------------
606 // Function resize
607 // ----------------------------------------------------------------------------
608 
609 template <typename TContainer,
610           typename TSize,
611           typename TExpand>
612 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
613                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >,
614                             typename Size<typename RemoveReference<TContainer>::Type>::Type)
615 resize(TContainer && me,
616        TSize const s,
617        Tag<TExpand> const &)
618 {
619     me.resize(s);
620     return length(me);
621 }
622 
623 template <typename TContainer,
624           typename TSize,
625           typename TExpand>
626 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
627                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >,
628                             typename Size<typename RemoveReference<TContainer>::Type>::Type)
629 resize(TContainer && me,
630        TSize const s,
631        typename Value<typename RemoveReference<TContainer>::Type>::Type const & val,
632        Tag<TExpand> const &)
633 {
634     me.resize(s, val);
635     return length(me);
636 }
637 
638 // ----------------------------------------------------------------------------
639 // Function clear
640 // ----------------------------------------------------------------------------
641 
642 template <typename TContainer>
643 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
644                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
645 clear(TContainer && me)
646 {
647     me.clear();
648 }
649 
650 // ----------------------------------------------------------------------------
651 // Function value
652 // ----------------------------------------------------------------------------
653 
654 template <typename TContainer,
655           typename TPos>
656 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<TContainer> >,
657                                 HasSubscriptOperator<TContainer> >, typename Reference<TContainer>::Type)
658 value(TContainer & me, TPos const pos)
659 {
660     return me[pos];
661 }
662 
663 template <typename TContainer,
664           typename TPos>
665 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<TContainer> >,
666                                 HasSubscriptOperator<TContainer> >, typename Reference<TContainer const>::Type)
667 value(TContainer const & me, TPos const pos)
668 {
669     return me[pos];
670 }
671 
672 template <typename TContainer,
673           typename TPos>
674 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<TContainer> >,
675                                 HasSubscriptOperator<TContainer> >, typename Value<TContainer>::Type)
676 value(TContainer && me, TPos const pos)
677 {
678     return me[pos];
679 }
680 
681 // linear complexity for list and fwd list
682 template <typename TContainer,
683           typename TPos>
684 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<TContainer> >,
685                                 Not<HasSubscriptOperator<TContainer> > >, typename Reference<TContainer>::Type)
686 value(TContainer & me, TPos const pos)
687 {
688     return *(_iterStl(me, pos));
689 }
690 
691 template <typename TContainer,
692           typename TPos>
693 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<TContainer> >,
694                                 Not<HasSubscriptOperator<TContainer> > >, typename Reference<TContainer const>::Type)
695 value(TContainer const & me, TPos const pos)
696 {
697     return *(_iterStl(me, pos));
698 }
699 
700 template <typename TContainer,
701           typename TPos>
702 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<TContainer> >,
703                                 Not<HasSubscriptOperator<TContainer> > >, typename Value<TContainer>::Type)
704 value(TContainer && me, TPos const pos)
705 {
706     return *(_iterStl(me, pos));
707 }
708 
709 // --------------------------------------------------------------------------
710 // Function getValue
711 // --------------------------------------------------------------------------
712 
713 template <typename TContainer,
714           typename TPos>
715 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<TContainer> >,
716                                 HasSubscriptOperator<TContainer> >, typename Reference<TContainer const>::Type)
717 getValue(TContainer const & me, TPos const pos)
718 {
719     return me[pos];
720 }
721 
722 template <typename TContainer,
723           typename TPos>
724 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<TContainer> >,
725                                 HasSubscriptOperator<TContainer> >, typename Value<TContainer>::Type)
726 getValue(TContainer && me, TPos const pos)
727 {
728     return me[pos];
729 }
730 
731 // linear complexity for list and fwd list
732 template <typename TContainer,
733           typename TPos>
734 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<TContainer> >,
735                                 Not<HasSubscriptOperator<TContainer> > >, typename Reference<TContainer const>::Type)
736 getValue(TContainer const & me, TPos const pos)
737 {
738     return *(_iterStl(me, pos));
739 }
740 
741 template <typename TContainer,
742           typename TPos>
743 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<TContainer> >,
744                                 Not<HasSubscriptOperator<TContainer> > >, typename Value<TContainer>::Type)
745 getValue(TContainer && me, TPos const pos)
746 {
747     return *(_iterStl(me, pos));
748 }
749 
750 // ----------------------------------------------------------------------------
751 // Function front
752 // ----------------------------------------------------------------------------
753 
754 // default implementation used
755 
756 // ----------------------------------------------------------------------------
757 // Function back
758 // ----------------------------------------------------------------------------
759 
760 // default implementation used
761 
762 // forward_list doesnt have back, we achieve it in linear time
763 template <typename TChar, typename TAlloc>
764 inline TChar &
765 back(std::forward_list<TChar, TAlloc> & me)
766 {
767     return *(std::next(me.before_begin(), length(me)));
768 }
769 
770 template <typename TChar, typename TAlloc>
771 inline TChar const &
772 back(std::forward_list<TChar, TAlloc> const & me)
773 {
774     return *(std::next(me.before_begin(), length(me)));
775 }
776 
777 template <typename TChar, typename TAlloc>
778 inline TChar
779 back(std::forward_list<TChar, TAlloc> && me)
780 {
781     return *(std::next(me.before_begin(), length(me)));
782 }
783 
784 // ----------------------------------------------------------------------------
785 // Function assign
786 // ----------------------------------------------------------------------------
787 
788 template <typename TContainer>
789 inline SEQAN_FUNC_ENABLE_IF(Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >, void)
790 assign(TContainer && me,
791        typename RemoveReference<TContainer>::Type source)
792 {
793     std::swap(me, source);
794 }
795 
796 template <typename TContainer,
797           typename TSource>
798 inline SEQAN_FUNC_ENABLE_IF(And<Not<IsSameType<typename RemoveReference<TContainer>::Type, TSource> >,
799                                 Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> > >, void)
800 assign(TContainer && me,
801        TSource const & source)
802 {
803     me.assign(begin(source, Standard()), end(source, Standard()));
804 }
805 
806 template <typename TContainer,
807           typename TSource>
808 inline SEQAN_FUNC_ENABLE_IF(Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >, void)
809 assign(TContainer && me,
810        TSource const & source,
811        typename Size<TSource>::Type limit)
812 {
813     me.assign(begin(source, Standard()),
814               iter(source, std::min(length(source), limit), Standard()));
815 }
816 
817 // ----------------------------------------------------------------------------
818 // Function insert
819 // ----------------------------------------------------------------------------
820 
821 template <typename TContainer,
822           typename TSource,
823           typename TExpand>
824 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
825                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
826 insert(TContainer && me,
827        typename Size<typename RemoveReference<TContainer>::Type>::Type const pos,
828        TSource const & source,
829        Tag<TExpand> const &)
830 {
831     me.insert(_iterStl(std::forward<TContainer>(me), pos),
832               begin(source, Standard()),
833               end(source, Standard()));
834 }
835 
836 template <typename TContainer,
837           typename TSource,
838           typename TExpand>
839 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
840                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
841 insert(TContainer && me,
842        typename Size<typename RemoveReference<TContainer>::Type>::Type const pos,
843        TSource const & source,
844        typename Size<TSource>::Type const limit,
845        Tag<TExpand> const &)
846 {
847     me.insert(_iterStl(std::forward<TContainer>(me), pos),
848               begin(source, Standard()),
849               iter(source, std::min(length(source), limit), Standard()));
850 }
851 
852 // forward_list doesnt have insert, we achieve it slower
853 template <typename TChar, typename TAlloc, typename TSource, typename TExpand>
854 inline void
855 insert(std::forward_list<TChar, TAlloc> & me,
856        typename Size<std::forward_list<TChar, TAlloc> >::Type const pos,
857        TSource const & source,
858        Tag<TExpand> const &)
859 {
860     me.insert_after(std::next(me.before_begin(), pos), begin(source, Standard()), end(source, Standard()));
861 }
862 
863 template <typename TChar, typename TAlloc, typename TSource, typename TExpand>
864 inline void
865 insert(std::forward_list<TChar, TAlloc> && me,
866        typename Size<std::forward_list<TChar, TAlloc> >::Type const pos,
867        TSource const & source,
868        Tag<TExpand> const &)
869 {
870     insert(me, pos, source);
871 }
872 
873 template <typename TChar, typename TAlloc, typename TSource, typename TExpand>
874 inline void
875 insert(std::forward_list<TChar, TAlloc> & me,
876        typename Size<std::forward_list<TChar, TAlloc> >::Type const pos,
877        TSource const & source,
878        typename Size<std::forward_list<TChar, TAlloc> >::Type const limit,
879        Tag<TExpand> const &)
880 {
881     me.insert_after(std::next(me.before_begin(), pos),
882                     begin(source, Standard()),
883                     iter(source, std::min(length(source), limit), Standard()));
884 }
885 
886 template <typename TChar, typename TAlloc, typename TSource, typename TExpand>
887 inline void
888 insert(std::forward_list<TChar, TAlloc> && me,
889        typename Size<std::forward_list<TChar, TAlloc> >::Type const pos,
890        TSource const & source,
891        typename Size<std::forward_list<TChar, TAlloc> >::Type const limit,
892        Tag<TExpand> const &)
893 {
894     insert(me, pos, source, limit);
895 }
896 
897 // ----------------------------------------------------------------------------
898 // Function append
899 // ----------------------------------------------------------------------------
900 
901 template <typename TContainer,
902           typename TSource,
903           typename TExpand>
904 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
905                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
906 append(TContainer && me,
907        TSource const & source,
908        Tag<TExpand> const &)
909 {
910     insert(std::forward<TContainer>(me), length(me), source);
911 }
912 
913 template <typename TContainer,
914           typename TSource,
915           typename TExpand>
916 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
917                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
918 append(TContainer && me,
919        TSource const & source,
920        typename Size<typename RemoveReference<TContainer>::Type>::Type const limit,
921        Tag<TExpand> const &)
922 {
923     insert(std::forward<TContainer>(me), length(me), source, limit);
924 }
925 
926 // forward list is handled downstream in insert
927 
928 // ----------------------------------------------------------------------------
929 // Function prepend
930 // ----------------------------------------------------------------------------
931 
932 template <typename TContainer,
933           typename TSource>
934 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
935                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
936 prepend(TContainer && me,
937         TSource const & source)
938 {
939     insert(std::forward<TContainer>(me), 0, source);
940 }
941 
942 template <typename TContainer,
943           typename TSource,
944           typename TExpand>
945 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
946                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
947 prepend(TContainer && me,
948         TSource const & source,
949         Tag<TExpand> const &)
950 {
951     insert(std::forward<TContainer>(me), 0, source);
952 }
953 
954 template <typename TContainer,
955           typename TSource,
956           typename TExpand>
957 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
958                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
959 prepend(TContainer && me,
960         TSource const & source,
961         typename Size<typename RemoveReference<TContainer>::Type>::Type const limit)
962 {
963     insert(std::forward<TContainer>(me), 0, source, limit);
964 }
965 
966 template <typename TContainer,
967           typename TSource,
968           typename TExpand>
969 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
970                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
971 prepend(TContainer && me,
972         TSource const & source,
973         typename Size<typename RemoveReference<TContainer>::Type>::Type const limit,
974         Tag<TExpand> const &)
975 {
976     insert(std::forward<TContainer>(me), 0, source, limit);
977 }
978 
979 // forward list is handled downstream in insert
980 
981 // ----------------------------------------------------------------------------
982 // Function insertValue
983 // ----------------------------------------------------------------------------
984 
985 template <typename TContainer,
986           typename TSource,
987           typename TExpand>
988 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
989                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
990 insertValue(TContainer && me,
991             typename Size<typename RemoveReference<TContainer>::Type>::Type const pos,
992             TSource && source,
993             Tag<TExpand> const &)
994 {
995     me.insert(_iterStl(std::forward<TContainer>(me), pos), std::forward<TSource>(source));
996 }
997 
998 template <typename TChar, typename TAlloc, typename TSource, typename TExpand>
999 inline void
1000 insertValue(std::forward_list<TChar, TAlloc> & me,
1001             typename Size<std::forward_list<TChar, TAlloc> >::Type const pos,
1002             TSource && source,
1003             Tag<TExpand> const &)
1004 {
1005     me.insert_after(std::next(me.before_begin(), pos), std::forward<TSource>(source));
1006 }
1007 
1008 template <typename TChar, typename TAlloc, typename TSource, typename TExpand>
1009 inline void
1010 insertValue(std::forward_list<TChar, TAlloc> && me,
1011             typename Size<std::forward_list<TChar, TAlloc> >::Type const pos,
1012             TSource && source,
1013             Tag<TExpand> const &)
1014 {
1015     insertValue(me, pos, source);
1016 }
1017 
1018 // ----------------------------------------------------------------------------
1019 // Function appendValue
1020 // ----------------------------------------------------------------------------
1021 
1022 template <typename TContainer,
1023           typename TSource,
1024           typename TExpand>
1025 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
1026                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
1027 appendValue(TContainer && me,
1028             TSource && source,
1029             Tag<TExpand> const &)
1030 {
1031     me.push_back(std::forward<TSource>(source));
1032 }
1033 
1034 template <typename TChar, typename TAlloc, typename TSource, typename TExpand>
1035 inline void
1036 appendValue(std::forward_list<TChar, TAlloc> & me,
1037             TSource && source,
1038             Tag<TExpand> const &)
1039 {
1040     insertValue(me, length(me), std::forward<TSource>(source));
1041 }
1042 
1043 template <typename TChar, typename TAlloc, typename TSource, typename TExpand>
1044 inline void
1045 appendValue(std::forward_list<TChar, TAlloc> && me,
1046             TSource && source,
1047             Tag<TExpand> const &)
1048 {
1049     appendValue(me, source);
1050 }
1051 
1052 // ----------------------------------------------------------------------------
1053 // Function prependValue
1054 // ----------------------------------------------------------------------------
1055 
1056 template <typename TContainer,
1057           typename TSource>
1058 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
1059                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
1060 prependValue(TContainer && me,
1061              TSource && source)
1062 {
1063     me.push_front(std::forward<TSource>(source));
1064 }
1065 
1066 template <typename TContainer,
1067           typename TSource,
1068           typename TExpand>
1069 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
1070                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
1071 prependValue(TContainer && me,
1072              TSource && source,
1073              Tag<TExpand> const &)
1074 {
1075     prependValue(std::forward<TContainer>(me), std::forward<TSource>(source));
1076 }
1077 
1078 // vector and string dont have push_front, we achieve it in linear time
1079 template <typename TChar, typename TAlloc, typename TSource>
1080 inline void
1081 prependValue(std::vector<TChar, TAlloc> & me,
1082              TSource && source)
1083 {
1084     insertValue(me, 0, std::forward<TSource>(source));
1085 }
1086 
1087 template <typename TChar, typename TTraits, typename TAlloc, typename TSource>
1088 inline void
1089 prependValue(std::basic_string<TChar, TTraits, TAlloc> & me,
1090              TSource && source)
1091 {
1092     insertValue(me, 0, std::forward<TSource>(source));
1093 }
1094 
1095 // && to &
1096 template <typename TChar, typename TAlloc, typename TSource>
1097 inline void
1098 prependValue(std::vector<TChar, TAlloc> && me,
1099              TSource && source)
1100 {
1101     prependValue(me, std::forward<TSource>(source));
1102 }
1103 
1104 template <typename TChar, typename TTraits, typename TAlloc, typename TSource>
1105 inline void
1106 prependValue(std::basic_string<TChar, TTraits, TAlloc> && me,
1107              TSource && source)
1108 {
1109     prependValue(me, std::forward<TSource>(source));
1110 }
1111 
1112 // ----------------------------------------------------------------------------
1113 // Function erase
1114 // ----------------------------------------------------------------------------
1115 
1116 template <typename TContainer>
1117 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
1118                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
1119 erase(TContainer && me,
1120       typename Size<typename RemoveReference<TContainer>::Type>::Type const pos,
1121       typename Size<typename RemoveReference<TContainer>::Type>::Type const posEnd)
1122 {
1123     me.erase(_iterStl(me, pos), _iterStl(me, posEnd));
1124 }
1125 
1126 template <typename TChar, typename TAlloc>
1127 inline void
1128 erase(std::forward_list<TChar, TAlloc> & me,
1129       typename Size<std::forward_list<TChar, TAlloc> >::Type const pos,
1130       typename Size<std::forward_list<TChar, TAlloc> >::Type const posEnd)
1131 {
1132     me.erase_after(std::next(me.before_begin(), pos), std::next(me.begin(), posEnd));
1133 }
1134 
1135 template <typename TChar, typename TAlloc>
1136 inline void
1137 erase(std::forward_list<TChar, TAlloc> && me,
1138       typename Size<std::forward_list<TChar, TAlloc> >::Type const pos,
1139       typename Size<std::forward_list<TChar, TAlloc> >::Type const posEnd)
1140 {
1141     erase(me, pos, posEnd);
1142 }
1143 
1144 template <typename TContainer>
1145 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
1146                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
1147 erase(TContainer && me,
1148       typename Size<typename RemoveReference<TContainer>::Type>::Type const pos)
1149 {
1150     erase(std::forward<TContainer>(me), pos, pos + 1);
1151 }
1152 
1153 // ----------------------------------------------------------------------------
1154 // Function eraseFront
1155 // ----------------------------------------------------------------------------
1156 
1157 template <typename TContainer>
1158 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
1159                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
1160 eraseFront(TContainer && me)
1161 {
1162     me.pop_front();
1163 }
1164 
1165 template <typename TChar, typename TAlloc>
1166 inline void
1167 eraseFront(std::vector<TChar, TAlloc> & me)
1168 {
1169     me.erase(me.begin());
1170 }
1171 
1172 template <typename TChar, typename TTraits, typename TAlloc>
1173 inline void
1174 eraseFront(std::basic_string<TChar, TTraits, TAlloc> & me)
1175 {
1176     me.erase(me.begin());
1177 }
1178 
1179 template <typename TChar, typename TAlloc>
1180 inline void
1181 eraseFront(std::vector<TChar, TAlloc> && me)
1182 {
1183     me.erase(me.begin());
1184 }
1185 
1186 template <typename TChar, typename TTraits, typename TAlloc>
1187 inline void
1188 eraseFront(std::basic_string<TChar, TTraits, TAlloc> && me)
1189 {
1190     me.erase(me.begin());
1191 }
1192 
1193 // ----------------------------------------------------------------------------
1194 // Function eraseBack
1195 // ----------------------------------------------------------------------------
1196 
1197 template <typename TContainer>
1198 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
1199                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
1200 eraseBack(TContainer && me)
1201 {
1202     me.pop_back();
1203 }
1204 
1205 template <typename TChar, typename TAlloc>
1206 inline void
1207 eraseBack(std::forward_list<TChar, TAlloc> & me)
1208 {
1209     if (!empty(me))
1210     {
1211         auto it = me.before_begin(), itN = std::next(me.begin()), itEnd = me.end();
1212         while (itN != itEnd)
1213         {
1214             ++it;
1215             ++itN;
1216         }
1217         me.erase_after(it);
1218     }
1219 }
1220 
1221 template <typename TChar, typename TAlloc>
1222 inline void
1223 eraseBack(std::forward_list<TChar, TAlloc> && me)
1224 {
1225     eraseBack(me);
1226 }
1227 
1228 // ----------------------------------------------------------------------------
1229 // Function replace
1230 // ----------------------------------------------------------------------------
1231 
1232 template <typename TContainer,
1233           typename TSource,
1234           typename TExpand>
1235 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
1236                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
1237 replace(TContainer && me,
1238         typename Size<typename RemoveReference<TContainer>::Type>::Type const pos,
1239         typename Size<typename RemoveReference<TContainer>::Type>::Type const posEnd,
1240         TSource const & source,
1241         typename Size<TSource>::Type const limit,
1242         Tag<TExpand> const &)
1243 {
1244     erase(me, pos, posEnd);
1245     insert(me, pos, source, limit);
1246 }
1247 
1248 template <typename TContainer,
1249           typename TSource,
1250           typename TExpand>
1251 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<typename RemoveReference<TContainer>::Type> >,
1252                                 Not<FixedSize_<typename RemoveReference<TContainer>::Type> > >, void)
1253 replace(TContainer && me,
1254         typename Size<typename RemoveReference<TContainer>::Type>::Type const pos,
1255         typename Size<typename RemoveReference<TContainer>::Type>::Type const posEnd,
1256         TSource const & source,
1257         Tag<TExpand> const &)
1258 {
1259     erase(me, pos, posEnd);
1260     insert(me, pos, source, length(source));
1261 }
1262 
1263 // ----------------------------------------------------------------------------
1264 // Function reverse
1265 // ----------------------------------------------------------------------------
1266 
1267 // NOTE(h-2): seqan's reverse doesn't work for some stl containers
1268 template <typename TContainer>
1269 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<TContainer> >, HasSubscriptOperator<TContainer> >)
1270 reverse(TContainer && me)
1271 {
1272     std::reverse(me.begin(), me.end());
1273 }
1274 
1275 template <typename TContainer>
1276 inline SEQAN_FUNC_ENABLE_IF(And<Is<StlContainerConcept<TContainer> >, Not<HasSubscriptOperator<TContainer> > >)
1277 reverse(TContainer && me)
1278 {
1279     me.reverse();
1280 }
1281 
1282 // ----------------------------------------------------------------------------
1283 // Function toCString
1284 // ----------------------------------------------------------------------------
1285 
1286 template <typename TChar, typename TTraits, typename TAlloc>
1287 inline const TChar*
1288 toCString(std::basic_string<TChar, TTraits, TAlloc> const & me)
1289 {
1290     return me.c_str();
1291 }
1292 
1293 // ----------------------------------------------------------------------------
1294 // Function assign (from CString)
1295 // ----------------------------------------------------------------------------
1296 
1297 // NOTE(h-2): is this optimal if container is not Contiguous?
1298 template <typename TContainer>
1299 inline SEQAN_FUNC_ENABLE_IF(Is<StlContainerConcept<TContainer> >, void)
1300 assign(TContainer & me,
1301        char const * source)
1302 {
1303     resize(me, length(source));
1304     std::copy(source, source + std::strlen(source), me.begin());
1305 }
1306 
1307 template <typename TTraits, typename TAlloc>
1308 inline void
1309 assign(std::basic_string<char, TTraits, TAlloc> & me,
1310        char const * source)
1311 {
1312     me = source;
1313 }
1314 
1315 template <typename TContainer>
1316 inline SEQAN_FUNC_ENABLE_IF(Is<StlContainerConcept<TContainer> >, void)
1317 assign(TContainer && me,
1318        char const * source)
1319 {
1320     assign(me, source);
1321 }
1322 
1323 template <typename TTraits, typename TAlloc>
1324 inline void
1325 assign(std::basic_string<char, TTraits, TAlloc> && me,
1326        char const * source)
1327 {
1328     me = source;
1329 }
1330 
1331 }
1332 
1333 #undef SUPERMACRO__
1334 #undef COMMA
1335 
1336 #endif
1337