How can I check if a move constructor is being generated implicitly?

前端 未结 3 2039
一向
一向 2021-02-04 04:20

I have several classes for which I wish to check whether a default move constructor is being generated. Is there a way to check this (be it a compile-time assertion, or parsing

3条回答
  •  时光说笑
    2021-02-04 05:02

    As Yakk pointed out, it's often not relevant if it's compiler generated or not.

    You can check if a type is trivial or nothrow move constructable

    template< class T >
    struct is_trivially_move_constructible;
    
    template< class T >
    struct is_nothrow_move_constructible;
    

    http://en.cppreference.com/w/cpp/types/is_move_constructible

    Limitation; it also permits trivial/nothrow copy construction.

提交回复
热议问题