summaryrefslogtreecommitdiff
path: root/src/expr/node_value.h
diff options
context:
space:
mode:
authorMorgan Deters <mdeters@gmail.com>2010-10-07 21:42:51 +0000
committerMorgan Deters <mdeters@gmail.com>2010-10-07 21:42:51 +0000
commit557e6c09dcc9068e848796772bc775542f4fc599 (patch)
treef20e6c9b1b6c7312e99ecc89d8a4d45bd64642aa /src/expr/node_value.h
parentf7668d89c65b66a8aa5b17a19f56831d48878298 (diff)
NodeSelfIterator implementation and unit test (resolves bug #204); also fix ParserBlack unit test initialization
Diffstat (limited to 'src/expr/node_value.h')
-rw-r--r--src/expr/node_value.h23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/expr/node_value.h b/src/expr/node_value.h
index 658cb1e2d..b91196559 100644
--- a/src/expr/node_value.h
+++ b/src/expr/node_value.h
@@ -119,11 +119,8 @@ class NodeValue {
static size_t next_id;
-public:
/**
- * Uninitializing constructor for NodeBuilder's use. This is
- * somewhat dangerous, but must also be public for the
- * makeStackNodeBuilder() macro to work.
+ * Uninitializing constructor for NodeBuilder's use.
*/
NodeValue() { /* do not initialize! */ }
@@ -140,10 +137,11 @@ private:
const_nv_iterator nv_begin() const;
const_nv_iterator nv_end() const;
- template <typename T>
+ template <class T>
class iterator {
const_nv_iterator d_i;
public:
+ typedef std::random_access_iterator_tag iterator_category;
typedef T value_type;
typedef ptrdiff_t difference_type;
typedef T* pointer;
@@ -152,13 +150,18 @@ private:
iterator() : d_i(NULL) {}
explicit iterator(const_nv_iterator i) : d_i(i) {}
- inline T operator*();
+ // conversion of a TNode iterator to a Node iterator
+ inline operator NodeValue::iterator<NodeTemplate<true> >() {
+ return iterator<NodeTemplate<true> >(d_i);
+ }
+
+ inline T operator*() const;
- bool operator==(const iterator& i) {
+ bool operator==(const iterator& i) const {
return d_i == i.d_i;
}
- bool operator!=(const iterator& i) {
+ bool operator!=(const iterator& i) const {
return d_i != i.d_i;
}
@@ -201,8 +204,6 @@ private:
difference_type operator-(iterator i) {
return d_i - i.d_i;
}
-
- typedef std::random_access_iterator_tag iterator_category;
};/* class NodeValue::iterator<T> */
// operator+ (as a function) cannot be a template, so we have to
@@ -440,7 +441,7 @@ namespace CVC4 {
namespace expr {
template <typename T>
-inline T NodeValue::iterator<T>::operator*() {
+inline T NodeValue::iterator<T>::operator*() const {
return T(*d_i);
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback