未验证 提交 edd6680a 编写于 作者: C Chen Weihang 提交者: GitHub

Further simplify the C++ error info stack (#21093)

* simplify C++ error stack by rewrite Place, test=develop

* polish assignment overload func, test=develop
上级 e64d55f0
......@@ -76,7 +76,24 @@ struct IsCUDAPinnedPlace : public boost::static_visitor<bool> {
bool operator()(const CUDAPinnedPlace &cuda_pinned) const { return true; }
};
typedef boost::variant<CUDAPlace, CPUPlace, CUDAPinnedPlace> Place;
class Place : public boost::variant<CUDAPlace, CPUPlace, CUDAPinnedPlace> {
private:
using PlaceBase = boost::variant<CUDAPlace, CPUPlace, CUDAPinnedPlace>;
public:
Place() = default;
Place(const CPUPlace &cpu_place) : PlaceBase(cpu_place) {} // NOLINT
Place(const CUDAPlace &cuda_place) : PlaceBase(cuda_place) {} // NOLINT
Place(const CUDAPinnedPlace &cuda_pinned_place) // NOLINT
: PlaceBase(cuda_pinned_place) {}
bool operator<(const Place &place) const {
return PlaceBase::operator<(static_cast<const PlaceBase &>(place));
}
bool operator==(const Place &place) const {
return PlaceBase::operator==(static_cast<const PlaceBase &>(place));
}
};
using PlaceList = std::vector<Place>;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册