]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Provide operator<< for TableIndices.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 24 Sep 2009 22:07:00 +0000 (22:07 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 24 Sep 2009 22:07:00 +0000 (22:07 +0000)
git-svn-id: https://svn.dealii.org/trunk@19531 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/table_indices.h
deal.II/doc/news/changes.h

index 4670bdd6bc0e070036c998832935a6cf98ec644f..46d7c928cd00241c7bc0205a2fc1d8cb4e77095a 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2005, 2006 by the deal.II authors
+//    Copyright (C) 2005, 2006, 2009 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
 #include <base/config.h>
 #include <base/exceptions.h>
 
+// we only need output streams, but older compilers did not provide
+// them in a separate include file
+#ifdef HAVE_STD_OSTREAM_HEADER
+#  include <ostream>
+#else
+#  include <iostream>
+#endif
+
+
+
 DEAL_II_NAMESPACE_OPEN
 
 
@@ -58,7 +68,7 @@ class TableIndicesBase
                                       * used for the SymmetricTensor class.
                                       */
     void sort ();
-      
+
   protected:
                                      /**
                                       * Store the indices in an array.
@@ -407,7 +417,7 @@ class TableIndices<7> : public TableIndicesBase<7>
 template <int N>
 inline
 unsigned int
-TableIndicesBase<N>::operator [] (const unsigned int i) const 
+TableIndicesBase<N>::operator [] (const unsigned int i) const
 {
   Assert (i < N, ExcIndexRange (i, 0, N));
   return indices[i];
@@ -418,7 +428,7 @@ TableIndicesBase<N>::operator [] (const unsigned int i) const
 template <int N>
 inline
 bool
-TableIndicesBase<N>::operator == (const TableIndicesBase<N> &other) const 
+TableIndicesBase<N>::operator == (const TableIndicesBase<N> &other) const
 {
   for (unsigned int i=0; i<N; ++i)
     if (indices[i] != other.indices[i])
@@ -431,7 +441,7 @@ TableIndicesBase<N>::operator == (const TableIndicesBase<N> &other) const
 template <int N>
 inline
 bool
-TableIndicesBase<N>::operator != (const TableIndicesBase<N> &other) const 
+TableIndicesBase<N>::operator != (const TableIndicesBase<N> &other) const
 {
   return !(*this == other);
 }
@@ -475,7 +485,7 @@ TableIndicesBase<3>::sort ()
 
 
 inline
-TableIndices<1>::TableIndices () 
+TableIndices<1>::TableIndices ()
 {
   this->indices[0] = 0;
 }
@@ -491,7 +501,7 @@ TableIndices<1>::TableIndices (const unsigned int index1)
 
 
 inline
-TableIndices<2>::TableIndices () 
+TableIndices<2>::TableIndices ()
 {
   this->indices[0] = this->indices[1] = 0;
 }
@@ -509,7 +519,7 @@ TableIndices<2>::TableIndices (const unsigned int index1,
 
 
 inline
-TableIndices<3>::TableIndices () 
+TableIndices<3>::TableIndices ()
 {
   this->indices[0] = this->indices[1] = this->indices[2] = 0;
 }
@@ -633,6 +643,29 @@ TableIndices<7>::TableIndices (const unsigned int index1,
 }
 
 
+/**
+ * Output operator for indices; reports them in a list like this:
+ * <code>[i1,i2,...]</code>.
+ */
+template <int N>
+std::ostream &
+operator << (std::ostream &o,
+            const TableIndices<N> &indices)
+{
+  o << '[';
+  for (unsigned int i=0; i<N; ++i)
+    {
+      o << indices[i];
+      if (i+1 != N)
+       o << ',';
+    }
+  o << ']';
+
+  return o;
+}
+
+
+
 
 DEAL_II_NAMESPACE_CLOSE
 
index c8bddda1545af84b1a42259c9e68529ad77eb993..620070ca9fa48f6bcba98eb3d356141e2ecfcb96 100644 (file)
@@ -215,6 +215,12 @@ inconvenience this causes.
 <h3>base</h3>
 
 <ol>
+  <li><p>New: There is now an <code>operator @<@<</code> for the
+  TableIndices class.
+  <br>
+  (WB 2009/09/24)
+  </p></li>
+
   <li>
   <p>
   Fixed: If anything had been put into a LogStream object without flushing

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.