我有一个结构:
typedef struct Wire {
std::vector<gate_id_t> _enters_to;
gate_id_t _out_from;
bool _is_output;
void* _data;
int _sig;
Wire(bool out)
:_sig(NO_SIGNAL), _is_output(out),_out_from(NULL),_data(NULL)
{}
} Wire;
和初始化器宏:
#define INIT_WIRE {_sig:NO_SIGNAL, _is_output:false, _out_from:NULL, _data:NULL}
std::vector<Wire> wires;
wires.resize(new_size,Wire(false));
时,它有效。wires.resize(new_size);
然后wires[index]=INIT_WIRE;
时,我收到错误:error: no match for ‘operator=’ (operand types are ‘__gnu_cxx::__alloc_traits<std::allocator<Wire> >::value_type {aka Wire}’ and ‘<brace-enclosed initializer list>’)
const Wire INIT_WIRE = {_sig:NO_SIGNAL, _is_output:false, _out_from:NULL, _data:NULL};
时,我收到错误:error: could not convert ‘{2, false, 0l, 0l}’ from ‘<brace-enclosed initializer list>’ to ‘const Wire’