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

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

* polish assignment overload func, test=develop
custom_op_abi
Chen Weihang 6 years ago committed by GitHub
parent e64d55f04e
commit edd6680a71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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>;

Loading…
Cancel
Save