如何为boost :: varivant * to be equal to some A*?类型的参数设置值>

问题描述 投票:0回答:1

说我有

class A {
};
class B {
};

using AOrB = boost::variant <A,B>;

A* ptr2a = ....
AOrB* another_ptr2a = a;//this doesn't compile for me, what is the correct way to do it?

使用boost :: variant *是不好的做法吗?

说我有A类{}; B类{};使用AOrB = boost :: variant ; A* ptr2a = .... AOrB* another_ptr2a = a;//this doesn't compile for me, what is the correct way to do it? is using ...

c++ boost-variant
1个回答
0
投票

你不能。 AOrBA子对象或B子对象组成,这些对象都不能指向现有的A

您可以将A复制到AOrB

© www.soinside.com 2019 - 2024. All rights reserved.