diff src/ov-scalar.h @ 5943:c038c2947ee1

[project @ 2006-08-18 21:27:03 by jwe]
author jwe
date Fri, 18 Aug 2006 21:27:04 +0000
parents c20eb7330d13
children cdef72fcd206
line wrap: on
line diff
--- a/src/ov-scalar.h	Fri Aug 18 18:57:06 2006 +0000
+++ b/src/ov-scalar.h	Fri Aug 18 21:27:04 2006 +0000
@@ -36,6 +36,7 @@
 #include "oct-alloc.h"
 #include "str-vec.h"
 
+#include "gripes.h"
 #include "ov-base.h"
 #include "ov-re-mat.h"
 #include "ov-base-scalar.h"
@@ -159,10 +160,21 @@
     return retval;
   }
 
-  bool bool_value (void) const { return scalar; }
+  bool bool_value (bool warn = false) const
+  {
+    if (warn && scalar != 0 && scalar != 1)
+      gripe_logical_conversion ();
+
+    return scalar;
+  }
 
-  boolNDArray bool_array_value (void) const
-    { return boolNDArray (dim_vector (1, 1), scalar); }
+  boolNDArray bool_array_value (bool warn = false) const
+  {
+    if (warn && scalar != 0 && scalar != 1)
+      gripe_logical_conversion ();
+
+    return boolNDArray (dim_vector (1, 1), scalar);
+  }
 
   std::streamoff streamoff_value (void) const;