lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [5770] Enforce a precondition; improve documentation


From: Greg Chicares
Subject: [lmi-commits] [5770] Enforce a precondition; improve documentation
Date: Wed, 18 Sep 2013 14:59:43 +0000

Revision: 5770
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5770
Author:   chicares
Date:     2013-09-18 14:59:43 +0000 (Wed, 18 Sep 2013)
Log Message:
-----------
Enforce a precondition; improve documentation

Modified Paths:
--------------
    lmi/trunk/expression_template_0_test.cpp

Modified: lmi/trunk/expression_template_0_test.cpp
===================================================================
--- lmi/trunk/expression_template_0_test.cpp    2013-09-18 12:50:26 UTC (rev 
5769)
+++ lmi/trunk/expression_template_0_test.cpp    2013-09-18 14:59:43 UTC (rev 
5770)
@@ -316,26 +316,29 @@
 }
 #endif // defined USE_UBLAS
 
-// See comment in mete_pete_typical().
-//
-// operator^=() or operator<<=() would probably be better, but would
-// require changing the PETE sources, whereas the normally-undefined
-// macro PETE_ALLOW_SCALAR_SHIFT leaves operator<<() available without
-// any such change. But is this syntactic sugar sweet enough?
+/// Syntactic sugar: "assignment" operator for expression templates.
+///
+/// PETE doesn't support this:
+///    std::vector<double> v2 = v0 - v1;
+/// because it's impossible to intrude a copy-assignment operator into
+/// the standard class template.
+///
+/// operator^=() or operator<<=() would probably be better, but would
+/// require changing the PETE sources, whereas the normally-undefined
+/// macro PETE_ALLOW_SCALAR_SHIFT leaves operator<<() available without
+/// any such change. But is this syntactic sugar sweet enough?
 
 template<typename T, typename V>
 std::vector<T>& operator<<(std::vector<T>& t, V v)
 {
+#if defined PETE_ALLOW_SCALAR_SHIFT
+#   error PETE_ALLOW_SCALAR_SHIFT must not be defined.
+#endif // defined PETE_ALLOW_SCALAR_SHIFT
     return assign(t, v);
 }
 
 void mete_pete_typical()
 {
-// PETE doesn't support this:
-//    std::vector<double> pv8 = pv0 - pv1;
-// because it's impossible to intrude a copy-assignment operator into
-// the standard class template.
-//
 // With the operator<<() above, this:
 //    std::vector<double> pv7a(pv0.size()); assign(pv7a, pv0 - pv1);
 // could be written thus:




reply via email to

[Prev in Thread] Current Thread [Next in Thread]