Changeset 3ad7978 for src/Common


Ignore:
Timestamp:
Mar 14, 2017, 11:06:40 AM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
c54b0b4
Parents:
68ac32e
Message:

Added map_range method (like transform but return a new container)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/utility.h

    r68ac32e r3ad7978  
    265265reverse_iterate_t< T > reverseIterate( T & ref ) {
    266266        return reverse_iterate_t< T >( ref );
     267}
     268
     269template< typename OutType, typename Range, typename Functor >
     270OutType map_range( const Range& range, Functor&& functor ) {
     271        OutType out;
     272
     273        std::transform(
     274                begin( range ),
     275                end( range ),
     276                std::back_inserter( out ),
     277                std::forward< Functor >( functor )
     278        );
     279
     280        return out;
    267281}
    268282
Note: See TracChangeset for help on using the changeset viewer.