|
1 //======================================================================= |
|
2 // Copyright 2002 Indiana University. |
|
3 // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek |
1 // |
4 // |
2 // Boost.Pointer Container |
5 // Distributed under the Boost Software License, Version 1.0. (See |
3 // |
6 // accompanying file LICENSE_1_0.txt or copy at |
4 // Copyright Thorsten Ottosen 2003-2005. Use, modification and |
7 // http://www.boost.org/LICENSE_1_0.txt) |
5 // distribution is subject to the Boost Software License, Version |
8 //======================================================================= |
6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
|
7 // http://www.boost.org/LICENSE_1_0.txt) |
|
8 // |
|
9 // For more information, see http://www.boost.org/libs/ptr_container/ |
|
10 // |
|
11 |
9 |
12 #ifndef BOOST_PTR_CONTAINER_EXCEPTION_HPP |
10 #ifndef BOOST_GRAPH_EXCEPTION_HPP |
13 #define BOOST_PTR_CONTAINER_EXCEPTION_HPP |
11 #define BOOST_GRAPH_EXCEPTION_HPP |
14 |
12 |
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200) |
13 #include <stdexcept> |
16 # pragma once |
14 #include <string> |
17 #endif |
|
18 |
15 |
19 #include <exception> |
16 namespace boost { |
20 |
17 |
21 namespace boost |
18 struct bad_graph : public std::invalid_argument { |
22 { |
19 bad_graph(const std::string& what_arg) |
23 class bad_ptr_container_operation : public std::exception |
20 : std::invalid_argument(what_arg) { } |
24 { |
21 }; |
25 const char* what_; |
|
26 public: |
|
27 bad_ptr_container_operation( const char* what ) : what_( what ) |
|
28 { } |
|
29 |
|
30 virtual const char* what() const throw() |
|
31 { |
|
32 return what_; |
|
33 } |
|
34 }; |
|
35 |
22 |
|
23 struct not_a_dag : public bad_graph { |
|
24 not_a_dag() |
|
25 : bad_graph("The graph must be a DAG.") { } |
|
26 }; |
36 |
27 |
37 |
28 struct negative_edge : public bad_graph { |
38 class bad_index : public bad_ptr_container_operation |
29 negative_edge() |
39 { |
30 : bad_graph("The graph may not contain an edge with negative weight."){ } |
40 public: |
31 }; |
41 bad_index( const char* what ) : bad_ptr_container_operation( what ) |
|
42 { } |
|
43 }; |
|
44 |
32 |
|
33 struct negative_cycle : public bad_graph { |
|
34 negative_cycle() |
|
35 : bad_graph("The graph may not contain negative cycles.") { } |
|
36 }; |
|
37 struct not_connected : public bad_graph { |
|
38 not_connected() |
|
39 : bad_graph("The graph must be connected.") { } |
|
40 }; |
45 |
41 |
|
42 } // namespace boost |
46 |
43 |
47 class bad_pointer : public bad_ptr_container_operation |
44 #endif // BOOST_GRAPH_EXCEPTION_HPP |
48 { |
|
49 public: |
|
50 bad_pointer() : bad_ptr_container_operation( "Null pointer not allowed in a pointer container!" ) |
|
51 { } |
|
52 |
|
53 bad_pointer( const char* text ) : bad_ptr_container_operation( text ) |
|
54 { } |
|
55 }; |
|
56 } |
|
57 |
|
58 #endif |
|