Ignore:
Timestamp:
Aug 11, 2017, 10:55:14 AM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
03321e4, f196351
Parents:
3b4571b (diff), 54cd58b (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' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/utility.h

    r3b4571b r67a67af  
    2424#include <sstream>
    2525#include <string>
     26#include <type_traits>
    2627
    2728#include <cassert>
     
    304305// for ( val : group_iterate( container1, container2, ... ) ) {}
    305306// syntax to have a for each that iterates multiple containers of the same length
    306 // TODO: update to use variadic arguments, perfect forwarding
     307// TODO: update to use variadic arguments
    307308
    308309template< typename T1, typename T2 >
     
    313314
    314315        struct iterator {
    315                 typedef std::tuple<typename T1::value_type, typename T2::value_type> value_type;
    316                 typedef typename T1::iterator T1Iter;
    317                 typedef typename T2::iterator T2Iter;
     316                typedef typename std::remove_reference<T1>::type T1val;
     317                typedef typename std::remove_reference<T2>::type T2val;
     318                typedef std::tuple<typename T1val::value_type &, typename T2val::value_type &> value_type;
     319                typedef typename T1val::iterator T1Iter;
     320                typedef typename T2val::iterator T2Iter;
    318321                typedef std::tuple<T1Iter, T2Iter> IterTuple;
    319322                IterTuple it;
     
    323326                }
    324327                bool operator!=( const iterator &other ) const { return it != other.it; }
    325                 value_type operator*() const { return std::make_tuple( *std::get<0>(it), *std::get<1>(it) ); }
     328                value_type operator*() const { return std::tie( *std::get<0>(it), *std::get<1>(it) ); }
    326329        };
    327330        iterator begin() { return iterator( std::get<0>(args).begin(), std::get<1>(args).begin() ); }
     
    333336
    334337template< typename... Args >
    335 group_iterate_t<Args...> group_iterate( const Args &... args ) {
    336         return group_iterate_t<Args...>(args...);
     338group_iterate_t<Args...> group_iterate( Args &&... args ) {
     339        return group_iterate_t<Args...>(std::forward<Args>( args )...);
    337340}
    338341
Note: See TracChangeset for help on using the changeset viewer.