Skip to content
Snippets Groups Projects
Commit 98b4af78 authored by Christian Engwer's avatar Christian Engwer
Browse files

add operators ">" ">=" "<" and "<=" to FieldVector<1>. The problem is

that std::array defines these operators aswell and c++ prefers to
complain about an inaccesible base class, rather than using the cast
operator :-(

[[Imported from SVN: r6167]]
parent 9b597073
No related branches found
No related tags found
No related merge requests found
......@@ -17,9 +17,9 @@
namespace Dune {
// forward declaration of template
template<class K, int SIZE> class FieldVector;
template<class K, unsigned int SIZE> class FieldVector;
template<class K, int SIZE>
template<class K, unsigned int SIZE>
struct FieldTraits< FieldVector<K,SIZE> >
{
typedef typename FieldTraits<K>::field_type field_type;
......@@ -40,7 +40,7 @@ namespace Dune {
* \tparam K the field type (use float, double, complex, etc)
* \tparam SIZE number of components.
*/
template< class K, int SIZE >
template< class K, unsigned int SIZE >
class FieldVector : public DenseVector< Dune::array<K,SIZE> >
{
public:
......@@ -82,7 +82,7 @@ namespace Dune {
*
* \returns the input stream (in)
*/
template<class K, int SIZE>
template<class K, unsigned int SIZE>
inline std::istream &operator>> ( std::istream &in,
FieldVector<K, SIZE> &v )
{
......@@ -100,29 +100,19 @@ namespace Dune {
#ifndef DOXYGEN
/** \brief Vectors containing only one component
*/
template< class K >
class FieldVector< K, 1 > : public DenseVector< Dune::array<K,1> >
template<class K>
class FieldVector<K, 1> : public DenseVector< Dune::array<K,1> >
{
public:
//===== type definitions and constants
//! export the type representing the field
typedef K field_type;
//! export the type representing the components
typedef K block_type;
//! The type for the index access and size operations.
typedef std::size_t size_type;
//! We are at the leaf of the block recursion
enum {blocklevel = 1};
//! export size
enum {size = 1};
enum {
//! The size of this vector.
dimension = 1,
//! The size of this vector.
size = 1
};
//! export size
enum {dimension = 1};
typedef typename DenseVector< Dune::array<K,1> >::size_type size_type;
//===== construction
......@@ -157,6 +147,34 @@ namespace Dune {
return a[0]-b[0];
}
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator> (const FieldVector<K,1>& a, const FieldVector<K,1>& b)
{
return a[0]>b[0];
}
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator>= (const FieldVector<K,1>& a, const FieldVector<K,1>& b)
{
return a[0]>=b[0];
}
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator< (const FieldVector<K,1>& a, const FieldVector<K,1>& b)
{
return a[0]<b[0];
}
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator<= (const FieldVector<K,1>& a, const FieldVector<K,1>& b)
{
return a[0]<=b[0];
}
//! Binary addition, when using FieldVector<K,1> like K
template<class K>
inline FieldVector<K,1> operator+ (const FieldVector<K,1>& a, const K b)
......@@ -171,6 +189,35 @@ namespace Dune {
return a[0]-b;
}
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator> (const FieldVector<K,1>& a, const K b)
{
return a[0]>b;
}
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator>= (const FieldVector<K,1>& a, const K b)
{
return a[0]>=b;
}
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator< (const FieldVector<K,1>& a, const K b)
{
return a[0]<b;
}
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator<= (const FieldVector<K,1>& a, const K b)
{
return a[0]<=b;
}
//! Binary addition, when using FieldVector<K,1> like K
template<class K>
inline FieldVector<K,1> operator+ (const K a, const FieldVector<K,1>& b)
......@@ -184,6 +231,34 @@ namespace Dune {
{
return a-b[0];
}
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator> (const K a, const FieldVector<K,1>& b)
{
return a>b[0];
}
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator>= (const K a, const FieldVector<K,1>& b)
{
return a>=b[0];
}
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator< (const K a, const FieldVector<K,1>& b)
{
return a<b[0];
}
//! Binary compare, when using FieldVector<K,1> like K
template<class K>
inline bool operator<= (const K a, const FieldVector<K,1>& b)
{
return a<=b[0];
}
#endif
/** @} end documentation */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment