Ignore:
Timestamp:
Mar 19, 2011, 9:13:12 PM (13 years ago)
Author:
イグトランス (egtra)
Message:

ab_commonにおいて、各クラスのコピー禁止を明確化、ならびにコピー可能なものにムーブコンストラクタ・ムーブ代入演算子を追加

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/egtra/ab5.0/abdev/ab_common/include/Lexical/Type.h

    r750 r816  
    6666      index( (LONG_PTR)&objClass ){}
    6767
    68     Type( const Type &type )
    69         : basicType( type.basicType )
    70         , index( type.index )
    71         , actualGenericTypes( type.actualGenericTypes )
    72         , formalTypeName( type.formalTypeName )
    73         , formalTypeIndex( type.formalTypeIndex )
     68    Type(Type&& type)
     69        : basicType(std::move(type.basicType))
     70        , index(std::move(type.index))
     71        , actualGenericTypes(std::move(type.actualGenericTypes))
     72        , formalTypeName(std::move(type.formalTypeName))
     73        , formalTypeIndex(std::move(type.formalTypeIndex))
     74    {
     75    }
     76
     77    Type(Type const& type)
     78        : basicType(type.basicType)
     79        , index(type.index)
     80        , actualGenericTypes(type.actualGenericTypes)
     81        , formalTypeName(type.formalTypeName)
     82        , formalTypeIndex(type.formalTypeIndex)
    7483    {
    7584    }
     
    7786    ~Type();
    7887
    79     void operator= ( const Type &type )
    80     {
    81         basicType = type.basicType;
    82         index = type.index;
    83         actualGenericTypes = type.actualGenericTypes;
    84         formalTypeName = type.formalTypeName;
    85         formalTypeIndex = type.formalTypeIndex;
    86     }
    87 
    88     __inline int GetBasicType() const
     88    Type& operator =(Type&& type)
     89    {
     90        basicType = std::move(type.basicType);
     91        index = std::move(type.index);
     92        actualGenericTypes = std::move(type.actualGenericTypes);
     93        formalTypeName = std::move(type.formalTypeName);
     94        formalTypeIndex = std::move(type.formalTypeIndex);
     95        return *this;
     96    }
     97
     98    Type& operator =(Type const& type)
     99    {
     100        return *this = Type(type);
     101    }
     102
     103    inline int GetBasicType() const
    89104    {
    90105        return basicType;
     
    253268
    254269public:
     270    Types() {}
     271    Types(Types&& y) : std::vector<Type>(std::move(y)) {}
     272    Types(Types const& y) : std::vector<Type>(y) {}
     273
     274    Types& operator =(Types&& y)
     275    {
     276        std::vector<Type>::operator =(std::move(y));
     277        return *this;
     278    }
     279
     280    Types& operator =(Types const& y)
     281    {
     282        return *this = std::move(Types(y));
     283    }
     284
    255285    bool IsEquals( const Types &Types ) const;
    256286};
     
    281311
    282312public:
    283     GenericType( const std::string &name, const Type &type )
    284         : name( name )
    285         , type( type )
    286     {
    287     }
     313    GenericType( std::string name, Type type )
     314        : name(std::move(name))
     315        , type(std::move(type))
     316    {
     317    }
     318
    288319    GenericType()
    289320    {
    290321    }
     322
     323    GenericType(GenericType&& y)
     324        : name(std::move(y.name))
     325        , type(std::move(y.type))
     326    {
     327    }
     328
     329    GenericType(GenericType const& y)
     330        : name(y.name)
     331        , type(y.type)
     332    {
     333    }
     334
     335    GenericType& operator =(GenericType&& y)
     336    {
     337        name = std::move(y.name);
     338        type = std::move(y.type);
     339        return *this;
     340    }
     341
     342    GenericType& operator =(GenericType const& y)
     343    {
     344        return *this = std::move(GenericType(y));
     345    }
     346
    291347    ~GenericType()
    292348    {
     
    329385    {
    330386    }
     387
    331388    BlittableType()
    332     {
    333     }
     389        : basicType()
     390        , pClass()
     391    {
     392    }
     393
     394    BlittableType(BlittableType&& y)
     395        : basicType(std::move(y.basicType))
     396        , pClass(std::move(y.pClass))
     397    {
     398    }
     399
     400    BlittableType(BlittableType const& y)
     401        : basicType(y.basicType)
     402        , pClass(y.pClass)
     403    {
     404    }
     405
     406    BlittableType& operator =(BlittableType&& y)
     407    {
     408        basicType = std::move(y.basicType);
     409        pClass = std::move(y.pClass);
     410        return *this;
     411    }
     412
     413    BlittableType& operator =(BlittableType const& y)
     414    {
     415        return *this = std::move(BlittableType(y));
     416    }
     417
    334418    const Type &GetBasicType() const
    335419    {
     
    344428    virtual bool Resolve( const ObjectModule &resolver, ResolveErrors &resolveErrors );
    345429};
     430
    346431class BlittableTypes : public std::vector<BlittableType>
    347432{
     
    358443
    359444public:
     445    BlittableTypes() {}
     446    BlittableTypes(BlittableTypes&& y) : std::vector<BlittableType>(std::move(y)) {}
     447    BlittableTypes(BlittableTypes const& y) : std::vector<BlittableType>(y) {}
     448    BlittableTypes& operator =(BlittableTypes&& y)
     449    {
     450        std::vector<BlittableType>::operator =(std::move(y));
     451        return *this;
     452    }
     453    BlittableTypes& operator =(BlittableTypes const& y)
     454    {
     455        return *this = std::move(BlittableTypes(y));
     456    }
     457
    360458    bool IsExist( Type type ) const
    361459    {
Note: See TracChangeset for help on using the changeset viewer.