Changeset 234b1cb for src/Common


Ignore:
Timestamp:
Jun 20, 2019, 2:32:55 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
b8524ca, f5edcb4
Parents:
c0f9efe
Message:

Port TupleAssignment to new AST

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/utility.h

    rc0f9efe r234b1cb  
    1616#pragma once
    1717
     18#include <cassert>
    1819#include <cctype>
    1920#include <algorithm>
     
    2728#include <type_traits>
    2829#include <utility>
    29 
    30 #include <cassert>
     30#include <vector>
    3131
    3232#include "Common/Indenter.h"
     
    145145                return ret;
    146146        } // switch
     147}
     148
     149/// Splice src onto the end of dst, clearing src
     150template< typename T >
     151void splice( std::vector< T > & dst, std::vector< T > & src ) {
     152        dst.reserve( dst.size() + src.size() );
     153        for ( T & x : src ) { dst.emplace_back( std::move( x ) ); }
     154        src.clear();
     155}
     156
     157/// Splice src onto the begining of dst, clearing src
     158template< typename T >
     159void spliceBegin( std::vector< T > & dst, std::vector< T > & src ) {
     160        splice( src, dst );
     161        dst.swap( src );
    147162}
    148163
Note: See TracChangeset for help on using the changeset viewer.