Ignore:
Timestamp:
Jul 4, 2017, 9:40:16 AM (8 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:
208e5be
Parents:
9c951e3 (diff), f7cb0bc (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into references

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/utility.h

    r9c951e3 rb1e63ac5  
    246246};
    247247
     248template< typename T >
     249struct ValueGuardPtr {
     250        T old;
     251        T* ref;
     252
     253        ValueGuardPtr(T * inRef) : old( inRef ? *inRef : T() ), ref(inRef) {}
     254        ~ValueGuardPtr() { if( ref ) *ref = old; }
     255};
     256
     257template< typename T >
     258struct ValueGuardPtr< std::list< T > > {
     259        std::list< T > old;
     260        std::list< T >* ref;
     261
     262        ValueGuardPtr( std::list< T > * inRef) : old(), ref(inRef) {
     263                if( ref ) { swap( *ref, old ); }
     264        }
     265        ~ValueGuardPtr() { if( ref ) { swap( *ref, old ); } }
     266};
     267
    248268// -----------------------------------------------------------------------------
    249269// Helper struct and function to support
     
    285305// for ( val : group_iterate( container1, container2, ... ) ) {}
    286306// syntax to have a for each that iterates multiple containers of the same length
    287 // TODO: update to use variadic arguments
     307// TODO: update to use variadic arguments, perfect forwarding
    288308
    289309template< typename T1, typename T2 >
     
    334354        {}
    335355
     356        CodeLocation( const CodeLocation& rhs ) = default;
     357
    336358        bool isSet () const {
    337359                return -1 != linenumber;
Note: See TracChangeset for help on using the changeset viewer.