remove custom assert system and use plain standard asserts instead.

we don't need no complication.
This commit is contained in:
Benoit Jacob 2007-06-01 07:16:33 +00:00
parent 8c001c1342
commit 887ff84376
3 changed files with 14 additions and 81 deletions

View File

@ -24,12 +24,12 @@
#ifndef TVMET_MATRIX_H
#define TVMET_MATRIX_H
#include <iterator> // reverse_iterator
#include <iterator> // reverse_iterator
#include <cassert>
#include <tvmet/tvmet.h>
#include <tvmet/TypePromotion.h>
#include <tvmet/CommaInitializer.h>
#include <tvmet/RunTimeError.h>
#include <tvmet/xpr/Matrix.h>
#include <tvmet/xpr/MatrixRow.h>
@ -92,7 +92,7 @@ public:
public: // access operators
/** access by index. */
value_type operator()(std::size_t i, std::size_t j) const {
TVMET_RT_CONDITION((i < Rows) && (j < Cols), "MatrixConstReference Bounce Violation")
assert((i < Rows) && (j < Cols));
return m_data[i * Cols + j];
}
@ -226,8 +226,7 @@ public:
template<class InputIterator>
explicit Matrix(InputIterator first, InputIterator last)
{
TVMET_RT_CONDITION(static_cast<std::size_t>(std::distance(first, last)) <= Size,
"InputIterator doesn't fits in size" )
assert(static_cast<std::size_t>(std::distance(first, last)) <= Size);
std::copy(first, last, m_data);
}
@ -238,7 +237,7 @@ public:
template<class InputIterator>
explicit Matrix(InputIterator first, std::size_t sz)
{
TVMET_RT_CONDITION(sz <= Size, "InputIterator doesn't fits in size" )
assert(sz <= Size);
std::copy(first, first + sz, m_data);
}
@ -269,12 +268,12 @@ public: // access operators
public: // index access operators
value_type& _tvmet_restrict operator()(std::size_t i, std::size_t j) {
// Note: g++-2.95.3 does have problems on typedef reference
TVMET_RT_CONDITION((i < Rows) && (j < Cols), "Matrix Bounce Violation")
assert((i < Rows) && (j < Cols));
return m_data[i * Cols + j];
}
value_type operator()(std::size_t i, std::size_t j) const {
TVMET_RT_CONDITION((i < Rows) && (j < Cols), "Matrix Bounce Violation")
assert((i < Rows) && (j < Cols));
return m_data[i * Cols + j];
}

View File

@ -1,65 +0,0 @@
/*
* Tiny Vector Matrix Library
* Dense Vector Matrix Libary of Tiny size using Expression Templates
*
* Copyright (C) 2001 - 2003 Olaf Petzold <opetzold@users.sourceforge.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id: RunTimeError.h,v 1.9 2003/11/30 08:26:25 opetzold Exp $
*/
#ifndef TVMET_RUN_TIME_ERROR_H
#define TVMET_RUN_TIME_ERROR_H
#include <cassert>
namespace tvmet {
/**
* \def TVMET_RT_CONDITION(XPR, MSG)
* \brief If TVMET_DEBUG is defined it checks the condition XPR and prints
* an error message MSG at runtime.
*/
#if defined(TVMET_DEBUG)
#define TVMET_RT_CONDITION(XPR, MSG) { \
if(!(XPR)) { \
std::cerr << "[tvmet] Precondition failure in " << __FILE__ \
<< ", line " << __LINE__ << ": " \
<< MSG << std::endl; \
std::cerr.flush(); \
assert(0); \
} \
}
#else
#define TVMET_RT_CONDITION(XPR, MSG)
#endif
} // namespace tvmet
#endif // TVMET_RUN_TIME_ERROR_H
// Local Variables:
// mode:C++
// End:

View File

@ -24,12 +24,12 @@
#ifndef TVMET_VECTOR_H
#define TVMET_VECTOR_H
#include <iterator> // reverse_iterator
#include <iterator> // reverse_iterator
#include <cassert>
#include <tvmet/tvmet.h>
#include <tvmet/TypePromotion.h>
#include <tvmet/CommaInitializer.h>
#include <tvmet/RunTimeError.h>
#include <tvmet/xpr/Vector.h>
@ -83,7 +83,7 @@ public:
public: // access operators
/** access by index. */
value_type operator()(std::size_t i) const {
TVMET_RT_CONDITION(i < Size, "VectorConstReference Bounce Violation")
assert(i < Size);
return m_data[i];
}
@ -214,8 +214,7 @@ public:
template<class InputIterator>
explicit Vector(InputIterator first, InputIterator last)
{
TVMET_RT_CONDITION( static_cast<std::size_t>(std::distance(first, last)) <= Size,
"InputIterator doesn't fits in size" )
assert( static_cast<std::size_t>(std::distance(first, last)) <= Size);
std::copy(first, last, m_data);
}
@ -226,7 +225,7 @@ public:
template<class InputIterator>
explicit Vector(InputIterator first, std::size_t sz)
{
TVMET_RT_CONDITION( sz <= Size, "InputIterator doesn't fits in size" )
assert(sz <= Size);
std::copy(first, first + sz, m_data);
}
@ -333,12 +332,12 @@ public: // access operators
public: // index access operators
value_type& _tvmet_restrict operator()(std::size_t i) {
// Note: g++-2.95.3 does have problems on typedef reference
TVMET_RT_CONDITION(i < Size, "Vector Bounce Violation")
assert(i < Size);
return m_data[i];
}
value_type operator()(std::size_t i) const {
TVMET_RT_CONDITION(i < Size, "Vector Bounce Violation")
assert(i < Size);
return m_data[i];
}