os/ossrv/ossrv_pub/boost_apis/boost/numeric/ublas/exception.hpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/numeric/ublas/exception.hpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,293 @@
     1.4 +//
     1.5 +//  Copyright (c) 2000-2002
     1.6 +//  Joerg Walter, Mathias Koch
     1.7 +//
     1.8 +//  Permission to use, copy, modify, distribute and sell this software
     1.9 +//  and its documentation for any purpose is hereby granted without fee,
    1.10 +//  provided that the above copyright notice appear in all copies and
    1.11 +//  that both that copyright notice and this permission notice appear
    1.12 +//  in supporting documentation.  The authors make no representations
    1.13 +//  about the suitability of this software for any purpose.
    1.14 +//  It is provided "as is" without express or implied warranty.
    1.15 +//
    1.16 +//  The authors gratefully acknowledge the support of
    1.17 +//  GeNeSys mbH & Co. KG in producing this work.
    1.18 +//
    1.19 +
    1.20 +#ifndef _BOOST_UBLAS_EXCEPTION_
    1.21 +#define _BOOST_UBLAS_EXCEPTION_
    1.22 +
    1.23 +#if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS)
    1.24 +#include <stdexcept>
    1.25 +#else
    1.26 +#include <cstdlib>
    1.27 +#endif
    1.28 +#ifndef BOOST_UBLAS_NO_STD_CERR
    1.29 +#include <iostream>
    1.30 +#endif
    1.31 +
    1.32 +#include <boost/numeric/ublas/detail/config.hpp>
    1.33 +
    1.34 +namespace boost { namespace numeric { namespace ublas {
    1.35 +
    1.36 +    struct divide_by_zero
    1.37 +#if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS)
    1.38 +        // Inherit from standard exceptions as requested during review.
    1.39 +        : public std::runtime_error {
    1.40 +        explicit divide_by_zero (const char *s = "divide by zero") :
    1.41 +            std::runtime_error (s) {}
    1.42 +        void raise () {
    1.43 +            throw *this;
    1.44 +        }
    1.45 +#else
    1.46 +    {
    1.47 +        divide_by_zero ()
    1.48 +            {}
    1.49 +        explicit divide_by_zero (const char *)
    1.50 +            {}
    1.51 +        void raise () {
    1.52 +            std::abort ();
    1.53 +        }
    1.54 +#endif
    1.55 +    };
    1.56 +
    1.57 +    struct internal_logic
    1.58 +#if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS)
    1.59 +        // Inherit from standard exceptions as requested during review.
    1.60 +        : public std::logic_error {
    1.61 +        explicit internal_logic (const char *s = "internal logic") :
    1.62 +            std::logic_error (s) {}
    1.63 +        void raise () {
    1.64 +            throw *this;
    1.65 +        }
    1.66 +#else
    1.67 +    {
    1.68 +        internal_logic ()
    1.69 +            {}
    1.70 +        explicit internal_logic (const char *)
    1.71 +            {}
    1.72 +        void raise () {
    1.73 +            std::abort ();
    1.74 +        }
    1.75 +#endif
    1.76 +    };
    1.77 +
    1.78 +    struct external_logic
    1.79 +#if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS)
    1.80 +        // Inherit from standard exceptions as requested during review.
    1.81 +        : public std::logic_error {
    1.82 +        explicit external_logic (const char *s = "external logic") :
    1.83 +            std::logic_error (s) {}
    1.84 +        // virtual const char *what () const throw () {
    1.85 +        //     return "exception: external logic";
    1.86 +        // }
    1.87 +        void raise () {
    1.88 +            throw *this;
    1.89 +        }
    1.90 +#else
    1.91 +    {
    1.92 +        external_logic ()
    1.93 +            {}
    1.94 +        explicit external_logic (const char *)
    1.95 +            {}
    1.96 +        void raise () {
    1.97 +            std::abort ();
    1.98 +        }
    1.99 +#endif
   1.100 +    };
   1.101 +
   1.102 +    struct bad_argument
   1.103 +#if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS)
   1.104 +        // Inherit from standard exceptions as requested during review.
   1.105 +        : public std::invalid_argument {
   1.106 +        explicit bad_argument (const char *s = "bad argument") :
   1.107 +            std::invalid_argument (s) {}
   1.108 +        void raise () {
   1.109 +            throw *this;
   1.110 +        }
   1.111 +#else
   1.112 +    {
   1.113 +        bad_argument ()
   1.114 +            {}
   1.115 +        explicit bad_argument (const char *)
   1.116 +            {}
   1.117 +        void raise () {
   1.118 +            std::abort ();
   1.119 +        }
   1.120 +#endif
   1.121 +    };
   1.122 +
   1.123 +    struct bad_size
   1.124 +#if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS)
   1.125 +        // Inherit from standard exceptions as requested during review.
   1.126 +        : public std::domain_error {
   1.127 +        explicit bad_size (const char *s = "bad size") :
   1.128 +            std::domain_error (s) {}
   1.129 +        void raise () {
   1.130 +            throw *this;
   1.131 +        }
   1.132 +#else
   1.133 +    {
   1.134 +        bad_size ()
   1.135 +            {}
   1.136 +        explicit bad_size (const char *)
   1.137 +            {}
   1.138 +        void raise () {
   1.139 +            std::abort ();
   1.140 +        }
   1.141 +#endif
   1.142 +    };
   1.143 +
   1.144 +    struct bad_index
   1.145 +#if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS)
   1.146 +        // Inherit from standard exceptions as requested during review.
   1.147 +        : public std::out_of_range {
   1.148 +        explicit bad_index (const char *s = "bad index") :
   1.149 +            std::out_of_range (s) {}
   1.150 +        void raise () {
   1.151 +            throw *this;
   1.152 +        }
   1.153 +#else
   1.154 +    {
   1.155 +        bad_index ()
   1.156 +            {}
   1.157 +        explicit bad_index (const char *)
   1.158 +            {}
   1.159 +        void raise () {
   1.160 +            std::abort ();
   1.161 +        }
   1.162 +#endif
   1.163 +    };
   1.164 +
   1.165 +    struct singular
   1.166 +#if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS)
   1.167 +        // Inherit from standard exceptions as requested during review.
   1.168 +        : public std::runtime_error {
   1.169 +        explicit singular (const char *s = "singular") :
   1.170 +            std::runtime_error (s) {}
   1.171 +        void raise () {
   1.172 +            throw *this;
   1.173 +        }
   1.174 +#else
   1.175 +    {
   1.176 +        singular ()
   1.177 +            {}
   1.178 +        explicit singular (const char *)
   1.179 +            {}
   1.180 +        void raise () {
   1.181 +            throw *this;
   1.182 +            std::abort ();
   1.183 +        }
   1.184 +#endif
   1.185 +    };
   1.186 +
   1.187 +    struct non_real
   1.188 +#if ! defined (BOOST_NO_EXCEPTIONS) && ! defined (BOOST_UBLAS_NO_EXCEPTIONS)
   1.189 +        // Inherit from standard exceptions as requested during review.
   1.190 +        : public std::domain_error {
   1.191 +        explicit non_real (const char *s = "exception: non real") :
   1.192 +            std::domain_error (s) {}
   1.193 +        void raise () {
   1.194 +            throw *this;
   1.195 +        }
   1.196 +#else
   1.197 +     {
   1.198 +        non_real ()
   1.199 +            {}
   1.200 +        explicit non_real (const char *)
   1.201 +            {}
   1.202 +        void raise () {
   1.203 +            std::abort ();
   1.204 +        }
   1.205 +#endif
   1.206 +    };
   1.207 +
   1.208 +#if BOOST_UBLAS_CHECK_ENABLE
   1.209 +// Macros are equivilent to 
   1.210 +//    template<class E>
   1.211 +//    BOOST_UBLAS_INLINE
   1.212 +//    void check (bool expression, const E &e) {
   1.213 +//        if (! expression)
   1.214 +//            e.raise ();
   1.215 +//    }
   1.216 +//    template<class E>
   1.217 +//    BOOST_UBLAS_INLINE
   1.218 +//    void check_ex (bool expression, const char *file, int line, const E &e) {
   1.219 +//        if (! expression)
   1.220 +//            e.raise ();
   1.221 +//    }
   1.222 +#ifndef BOOST_UBLAS_NO_STD_CERR
   1.223 +#define BOOST_UBLAS_CHECK_FALSE(e) \
   1.224 +    std::cerr << "Check failed in file " << __FILE__ << " at line " << __LINE__ << ":" << std::endl; \
   1.225 +    e.raise ();
   1.226 +#define BOOST_UBLAS_CHECK(expression, e) \
   1.227 +    if (! (expression)) { \
   1.228 +        std::cerr << "Check failed in file " << __FILE__ << " at line " << __LINE__ << ":" << std::endl; \
   1.229 +        std::cerr << #expression << std::endl; \
   1.230 +        e.raise (); \
   1.231 +    }
   1.232 +#define BOOST_UBLAS_CHECK_EX(expression, file, line, e) \
   1.233 +    if (! (expression)) { \
   1.234 +        std::cerr << "Check failed in file " << (file) << " at line " << (line) << ":" << std::endl; \
   1.235 +        std::cerr << #expression << std::endl; \
   1.236 +        e.raise (); \
   1.237 +    }
   1.238 +#else
   1.239 +#define BOOST_UBLAS_CHECK_FALSE(e) \
   1.240 +    e.raise ();
   1.241 +#define BOOST_UBLAS_CHECK(expression, e) \
   1.242 +    if (! (expression)) { \
   1.243 +        e.raise (); \
   1.244 +    }
   1.245 +#define BOOST_UBLAS_CHECK_EX(expression, file, line, e) \
   1.246 +    if (! (expression)) { \
   1.247 +        e.raise (); \
   1.248 +    }
   1.249 +#endif
   1.250 +#else
   1.251 +// Macros are equivilent to 
   1.252 +//    template<class E>
   1.253 +//    BOOST_UBLAS_INLINE
   1.254 +//    void check (bool expression, const E &e) {}
   1.255 +//    template<class E>
   1.256 +//    BOOST_UBLAS_INLINE
   1.257 +//    void check_ex (bool expression, const char *file, int line, const E &e) {}
   1.258 +#define BOOST_UBLAS_CHECK_FALSE(e)
   1.259 +#define BOOST_UBLAS_CHECK(expression, e)
   1.260 +#define BOOST_UBLAS_CHECK_EX(expression, file, line, e)
   1.261 +#endif
   1.262 +
   1.263 +
   1.264 +#ifndef BOOST_UBLAS_USE_FAST_SAME
   1.265 +// Macro is equivilent to 
   1.266 +//    template<class T>
   1.267 +//    BOOST_UBLAS_INLINE
   1.268 +//    const T &same_impl (const T &size1, const T &size2) {
   1.269 +//        BOOST_UBLAS_CHECK (size1 == size2, bad_argument ());
   1.270 +//        return (std::min) (size1, size2);
   1.271 +//    }
   1.272 +// #define BOOST_UBLAS_SAME(size1, size2) same_impl ((size1), (size2))
   1.273 +    template<class T>
   1.274 +    BOOST_UBLAS_INLINE
   1.275 +    // Kresimir Fresl and Dan Muller reported problems with COMO.
   1.276 +    // We better change the signature instead of libcomo ;-)
   1.277 +    // const T &same_impl_ex (const T &size1, const T &size2, const char *file, int line) {
   1.278 +    T same_impl_ex (const T &size1, const T &size2, const char *file, int line) {
   1.279 +        BOOST_UBLAS_CHECK_EX (size1 == size2, file, line, bad_argument ());
   1.280 +        return (std::min) (size1, size2);
   1.281 +    }
   1.282 +#define BOOST_UBLAS_SAME(size1, size2) same_impl_ex ((size1), (size2), __FILE__, __LINE__)
   1.283 +#else
   1.284 +// Macros are equivilent to 
   1.285 +//    template<class T>
   1.286 +//    BOOST_UBLAS_INLINE
   1.287 +//    const T &same_impl (const T &size1, const T &size2) {
   1.288 +//        return size1;
   1.289 +//    }
   1.290 +// #define BOOST_UBLAS_SAME(size1, size2) same_impl ((size1), (size2))
   1.291 +#define BOOST_UBLAS_SAME(size1, size2) (size1)
   1.292 +#endif
   1.293 +
   1.294 +}}}
   1.295 +
   1.296 +#endif