From 1c0a93cc0f14c3113191bc55b5a329e793979447 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Mon, 28 Apr 2014 10:38:41 +0200 Subject: [PATCH] * src/graph/graph.hh (trans_iterator): Respect the forward_iterator API. --- src/graph/graph.hh | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/graph/graph.hh b/src/graph/graph.hh index 60c8523b0..df41d77fd 100644 --- a/src/graph/graph.hh +++ b/src/graph/graph.hh @@ -25,6 +25,7 @@ #include #include #include +#include namespace spot { @@ -172,13 +173,29 @@ namespace spot // of that list. template - class SPOT_API trans_iterator + class SPOT_API trans_iterator: + std::iterator::value, + const typename Graph::trans_storage_t, + typename Graph::trans_storage_t>::type> { + typedef + std::iterator::value, + const typename Graph::trans_storage_t, + typename Graph::trans_storage_t>::type> + super; public: typedef typename Graph::transition transition; - typedef typename Graph::trans_storage_t trans_storage_t; - trans_iterator(Graph* g, transition t): t_(t), g_(g) + trans_iterator() + : g_(nullptr), t_(0) + { + } + + trans_iterator(Graph* g, transition t): g_(g), t_(t) { } @@ -192,9 +209,7 @@ namespace spot return t_ != o.t_; } - typename std::conditional::value, - const trans_storage_t&, - trans_storage_t&>::type + typename super::reference operator*() { return g_->trans_storage(t_); @@ -214,8 +229,8 @@ namespace spot } protected: - transition t_; Graph* g_; + transition t_; }; ////////////////////////////////////////////////// @@ -230,7 +245,7 @@ namespace spot public: typedef typename Graph::transition transition; state_out(Graph* g, transition t): - t_(t), g_(g) + g_(g), t_(t) { } @@ -241,7 +256,7 @@ namespace spot trans_iterator end() { - return {nullptr, 0}; + return {}; } void recycle(transition t) @@ -250,8 +265,8 @@ namespace spot } protected: - transition t_; Graph* g_; + transition t_; }; }