2424 * SOFTWARE.
2525 */
2626
27+ /* *
28+ * \file <pyqpp/classes/qcircuit_bind.hpp>
29+ * \brief Bindings for <qpp/classes/qcircuit.hpp>
30+ */
31+
2732#ifndef PYQPP_CLASSES_QCIRCUIT_BIND_HPP_
2833#define PYQPP_CLASSES_QCIRCUIT_BIND_HPP_
2934
3439
3540namespace {
3641
37- class WhileContext
38- {
39- public:
42+ class WhileContext {
43+ public:
4044 ~WhileContext () = default ;
4145 WhileContext (WhileContext&&) = default ;
4246
@@ -45,11 +49,11 @@ class WhileContext
4549
4650 py::object enter ();
4751
48- bool exit (std::optional<pybind11::type> const & /* exc_type */ ,
52+ bool exit (std::optional<pybind11::type> const & /* exc_type */ ,
4953 std::optional<pybind11::object> const & /* exc_value */ ,
5054 std::optional<pybind11::object> const & /* traceback */ );
5155
52- private:
56+ private:
5357 qpp::QCircuit& managed;
5458
5559 explicit WhileContext (qpp::QCircuit& qc) : managed(qc) {}
@@ -59,8 +63,7 @@ class WhileContext
5963 WhileContext& operator =(WhileContext const &) = delete ;
6064};
6165
62- WhileContext WhileContext::pyCreate (qpp::QCircuit& qc, qpp::cond_pred_t pred)
63- {
66+ WhileContext WhileContext::pyCreate (qpp::QCircuit& qc, qpp::cond_pred_t pred) {
6467 qc.cond_while (pred);
6568 return WhileContext (qc);
6669}
@@ -72,13 +75,12 @@ py::object WhileContext::enter() {
7275
7376bool WhileContext::exit (std::optional<pybind11::type> const &,
7477 std::optional<pybind11::object> const &,
75- std::optional<pybind11::object> const &)
76- {
78+ std::optional<pybind11::object> const &) {
7779 managed.cond_end ();
7880 return false ; // do not supress exceptions that occurred
7981}
8082
81- } /* anonymous namespace (for context managers in Python wrapping) */
83+ } // namespace
8284
8385/* qpp::QCircuit and related free functions */
8486inline void init_classes_qcircuit (py::module_& m) {
@@ -124,7 +126,7 @@ inline void init_classes_qcircuit(py::module_& m) {
124126 // wrap context manager
125127 auto pyWhileContext = py::class_<WhileContext>(m, " CondWhile" );
126128 pyWhileContext.def (" __enter__" , &WhileContext::enter)
127- .def (" __exit__" , &WhileContext::exit);
129+ .def (" __exit__" , &WhileContext::exit);
128130
129131 pyQCircuit.def (" cond_while_ctx" , &WhileContext::pyCreate,
130132 " Adds conditional while context" , py::arg (" pred" ));
0 commit comments