boost :: interprocess:为结构向量创建和插入元素(C ++ 03)

时间:2017-03-02 08:41:47

标签: c++ boost c++03 interprocess

我在使用msvc2008在boost :: interprocess中创建复杂结构的向量时遇到问题。之前提出的问题的答案(下面的链接)提供了一些解决方案,但它们都不适用于msvc2008。错误类型始终相同:

error: no match for ‘operator=’ (operand types are ‘complex_data’ and ‘const complex_data’) 

以前有关此问题的问题:

Shared memory Vectors in boost with

How to I create a boost interprocess vector of interprocess containers?

建议的解决方案:

http://coliru.stacked-crooked.com/a/10000376928990e2

http://coliru.stacked-crooked.com/a/3d6582c2d59015d2

注意:我知道我应该迁移到更新版本的Visual Studio。但遗憾的是,我目前仍然坚持使用msvc2008。

1 个答案:

答案 0 :(得分:0)

在不知道您的实际代码的情况下,您似乎应该为您的类型添加operator=,因为MSVC无法生成它(?)。

//Other members...
complex_data& operator=(complex_data const&) = default;

或者如果编译器没有采用该提示,则以老式的方式定义主体:

complex_data& operator=(complex_data const& rhs) {
    id_ = rhs.id_;
    char_string_ = rhs.char_string_;
    int_vector_ = rhs.int_vector_;
    return *this;
}