Initialization of member array of non-copyable, non-movable, explicitly constructed types

前端 未结 3 952
滥情空心
滥情空心 2020-12-21 06:16

A library which I can\'t modify has a type akin to the following:

class A {
  public:
    A () : A(0) { }
    explicit A (int const value) : value_(value) {          


        
3条回答
  •  北海茫月
    2020-12-21 06:40

    I am able to solve the problem as follows (also using SystemC, here my non-copyable, non-movable items are sc_modules):

    class Object : sc_module {
        Object(sc_module_name name){}
    };
    
    class Container : sc_module {
    
        std::array objects;
    
        Container(sc_module_name name) :
        objects{{{"object1"},{"object2"},{"object3"}}}
        {}
    };
    

提交回复
热议问题