小编sna*_*ulX的帖子

C++ 错误 C2280。为什么结构体不可复制

我在 C 项目中的头文件中有一个结构。

struct tgMethod {
    const char *name;
    const enum tgAccessModifier access;
    const enum tgMethodKind kind;
    tgTypeRef return_type;
    const tgParams params;
    const tgMethod *overrides;
    const void *userptr;
    const tgObject *(*methodptr)(tgObject *, size_t, tgObject *, void *);
};
Run Code Online (Sandbox Code Playgroud)

在链接这个 C 项目的 C++ 项目中,我有这个结构,它使用 asEntryAllocator<tgMethod>但编译器给出错误:error C2280: "tgMethod &tgMethod::operator =(const tgMethod &)": attempting to reference a deleted function

template<typename T>
struct EntryAllocator {
public:
    EntryAllocator() : EntryAllocator(1 << 7) { }

    explicit EntryAllocator(size_t max_size) :
                _start(0), _count(0), _capacity(max_size), _data((T*)calloc(max_size, …
Run Code Online (Sandbox Code Playgroud)

c++ struct copy-constructor

0
推荐指数
1
解决办法
117
查看次数

标签 统计

c++ ×1

copy-constructor ×1

struct ×1