Skip to content

Commit

Permalink
implement GatePtr NullPointerException
Browse files Browse the repository at this point in the history
  • Loading branch information
KowerKoint committed Jan 30, 2024
1 parent 82ca280 commit bd6b895
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion qulacs/gate/gate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ class GatePtr {
template <GateImpl U>
GatePtr(const GatePtr<U>& gate) : GatePtr(gate._gate_ptr) {}

T* operator->() const { return _gate_ptr.get(); }
T* operator->() const {
if (!_gate_ptr) {
throw std::runtime_error("GatePtr::operator->(): Gate is Null");
}
return _gate_ptr.get();
}
};
} // namespace internal

Expand Down

0 comments on commit bd6b895

Please sign in to comment.