Changeset 936 for trunk/yat/utility


Ignore:
Timestamp:
Oct 6, 2007, 1:02:08 AM (14 years ago)
Author:
Peter
Message:

reimplementing yat_assert as a throwing function

Location:
trunk/yat/utility
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/Iterator.h

    r932 r936  
    2929#include <iterator>
    3030#include <stddef.h>
     31#include <stdexcept>
    3132
    3233namespace theplu {
     
    6566     */
    6667    return_type operator*(void) const
    67     { yat_assert(index_<container_->size());
     68    { yat_assert<std::out_of_range>(index_<container_->size());
    6869      return container_->operator()(index_); }
    6970
     
    7273     */
    7374    return_type operator[](difference_type n) const
    74     { yat_assert(index_+n < container_->size());
     75    { yat_assert<std::out_of_range>(index_+n < container_->size());
    7576      return container_->operator()(index_+n); }
    7677
  • trunk/yat/utility/IteratorWeighted.h

    r916 r936  
    88#include <iterator>
    99#include <stddef.h>
     10#include <stdexcept>
    1011
    1112namespace theplu {
     
    4546    return_type operator*(void) const
    4647    {
    47       yat_assert(index_<container_->size());
     48      yat_assert<std::out_of_range>(index_<container_->size());
    4849      return container_->operator()(index_);
    4950    }
     
    5354    */
    5455    return_type data(void) const
    55     { yat_assert(index_<container_->size()); return container_->data(index_); }
     56    { yat_assert<std::out_of_range>(index_<container_->size());
     57      return container_->data(index_); }
    5658
    5759    /**
     
    5961    */
    6062    return_type weight(void) const
    61     { yat_assert(index_<container_->size());return container_->weight(index_); }
     63    { yat_assert<std::out_of_range>(index_<container_->size());
     64      return container_->weight(index_); }
    6265
    6366
  • trunk/yat/utility/yat_assert.h

    r921 r936  
    2424*/
    2525
    26 #include <cassert>
     26#include <string>
     27
     28namespace theplu {
     29namespace yat {
     30namespace utility {
     31
     32  template<class X> inline void yat_assert(bool assertion, std::string msg="")
    2733#ifdef YAT_DEBUG
    28 # define yat_assert(expr)   (assert(expr))
     34  { if (YAT_DEBUG && !assertion) throw X(msg); }
    2935#else
    30 # define yat_assert(expr)
     36  { }
    3137#endif
    3238
     39}}}
     40  /*
     41  */
    3342#endif
Note: See TracChangeset for help on using the changeset viewer.