From 8c78af2adcf3fe5fc103016ebc82c6c18c51a563 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 3 Jul 2015 15:42:25 +0200 Subject: [PATCH] bool conversion for record references (see also #477) I decided to allow for an 'unbound' reference to allow default construction of elements involving record references. I am aware of the implications, but I place the focus on the value nature of GenNode elements; the RecordRef was introduced only as a means to cary out diff comparisons and similar computations. --- src/lib/diff/record.hpp | 6 ++++++ tests/library/diff/generic-record-representation-test.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/diff/record.hpp b/src/lib/diff/record.hpp index 3f4d6f306..5a4ab6a3b 100644 --- a/src/lib/diff/record.hpp +++ b/src/lib/diff/record.hpp @@ -428,6 +428,12 @@ namespace diff{ // standard copy operations acceptable + explicit + operator bool() const + { + return bool(record_); + } + /** target is accessed by cast * @throws error::Logic on bottom reference */ diff --git a/tests/library/diff/generic-record-representation-test.cpp b/tests/library/diff/generic-record-representation-test.cpp index 3ae9245a5..d6603335c 100644 --- a/tests/library/diff/generic-record-representation-test.cpp +++ b/tests/library/diff/generic-record-representation-test.cpp @@ -306,7 +306,7 @@ namespace test{ RecordRef empty; CHECK (bool(empty) == false); CHECK (nullptr == empty.get()); - VERIFY_ERROR (BOTTOM_VALUE, RecS& (empty)); + VERIFY_ERROR (BOTTOM_VALUE, empty.operator RecS&() ); RecordRef ref(oo); CHECK (ref);