Changeset 4639b0d


Ignore:
Timestamp:
Sep 12, 2017, 7:01:34 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
7aa257ae, 7dc09294
Parents:
b3c7963
Message:

Fix memory error in lazy_map

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/utility.h

    rb3c7963 r4639b0d  
    376376template< typename T, typename Func >
    377377struct lambda_iterate_t {
    378         T & ref;
    379         Func f;
     378        const T & ref;
     379        std::function<Func> f;
    380380
    381381        struct iterator {
    382382                typedef decltype(begin(ref)) Iter;
    383383                Iter it;
    384                 Func f;
    385                 iterator( Iter it, Func f ) : it(it), f(f) {}
     384                std::function<Func> f;
     385                iterator( Iter it, std::function<Func> f ) : it(it), f(f) {}
    386386                iterator & operator++() {
    387387                        ++it; return *this;
     
    391391        };
    392392
    393         lambda_iterate_t( T & ref, Func f ) : ref(ref), f(f) {}
     393        lambda_iterate_t( const T & ref, std::function<Func> f ) : ref(ref), f(f) {}
    394394
    395395        auto begin() const -> decltype(iterator(std::begin(ref), f)) { return iterator(std::begin(ref), f); }
     
    398398
    399399template< typename... Args >
    400 lambda_iterate_t<Args...> lazy_map( Args &&... args ) {
    401         return lambda_iterate_t<Args...>(std::forward<Args>( args )...);
     400lambda_iterate_t<Args...> lazy_map( const Args &... args ) {
     401        return lambda_iterate_t<Args...>( args...);
    402402}
    403403
Note: See TracChangeset for help on using the changeset viewer.