BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslstl_badfunctioncall.h
Go to the documentation of this file.
1/// @file bslstl_badfunctioncall.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslstl_badfunctioncall.h -*-C++-*-
8#ifndef INCLUDED_BSLSTL_BADFUNCTIONCALL
9#define INCLUDED_BSLSTL_BADFUNCTIONCALL
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bslstl_badfunctioncall bslstl_badfunctioncall
15/// @brief Provide an exception class thrown by `bsl::function`.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslstl
19/// @{
20/// @addtogroup bslstl_badfunctioncall
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslstl_badfunctioncall-purpose"> Purpose</a>
25/// * <a href="#bslstl_badfunctioncall-classes"> Classes </a>
26/// * <a href="#bslstl_badfunctioncall-description"> Description </a>
27///
28/// # Purpose {#bslstl_badfunctioncall-purpose}
29/// Provide an exception class thrown by `bsl::function`.
30///
31/// # Classes {#bslstl_badfunctioncall-classes}
32///
33/// - bsl::bad_function_call: exception type thrown by `bsl::function`
34///
35/// **Canonical header:** bsl_functional.h
36///
37/// @see bslstl_function, bslstl_stdexceptionutil
38///
39/// # Description {#bslstl_badfunctioncall-description}
40/// This component provides a `bsl::bad_function_call` exception
41/// class. This exception is thrown by `bsl::function::operator()` when the
42/// function wrapper object has no target. If `std::function` implementation is
43/// available, `bsl::bad_function_call` is an alias to `std::bad_function_call`.
44///
45/// @}
46/** @} */
47/** @} */
48
49/** @addtogroup bsl
50 * @{
51 */
52/** @addtogroup bslstl
53 * @{
54 */
55/** @addtogroup bslstl_badfunctioncall
56 * @{
57 */
58
59#include <bslscm_version.h>
60
61#include <bsls_exceptionutil.h>
62#include <bsls_keyword.h>
64
65#ifdef BDE_BUILD_TARGET_EXC
66
67#include <exception>
68
69#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
70#include <functional> // for 'std::bad_function_call'
71#endif //BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
72
73namespace bsl {
74#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
75typedef std::bad_function_call bad_function_call;
76#else
77 // =======================
78 // class bad_function_call
79 // =======================
80
81class bad_function_call : public std::exception {
82 public:
83 // CREATORS
84
85 /// Create a `bad_function_call` object. Note that this function is
86 /// explicitly user-declared, to make it simple to declare `const`
87 /// objects of this type.
88 bad_function_call() BSLS_KEYWORD_NOEXCEPT;
89
90 // ACCESSORS
91
92 /// Return a pointer to the string literal "bad_function_call", with a
93 /// storage duration of the lifetime of the program. Note that the
94 /// caller should *not* attempt to free this memory. Note that the
95 /// @ref bsls_exceptionutil macro `BSLS_NOTHROW_SPEC` is deliberately not
96 /// used here, as a number of standard libraries declare `what` in the
97 /// base `exception` class explicitly with the no-throw specification,
98 /// even in a build that may not recognize exceptions.
99 const char *what() const BSLS_EXCEPTION_VIRTUAL_NOTHROW
101};
102
103// ============================================================================
104// INLINE DEFINITIONS
105// ============================================================================
106
107 // -------------------------
108 // class bad_function_call
109 // -------------------------
110
111inline
112bad_function_call::bad_function_call() BSLS_KEYWORD_NOEXCEPT
113: std::exception()
114{
115}
116
117inline
118const char *bad_function_call::what() const BSLS_EXCEPTION_VIRTUAL_NOTHROW
119{
120 return "bad_function_call";
121}
122#endif //BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
123
124} // close namespace bsl
125
126#endif //BDE_BUILD_TARGET_EXC
127#endif
128
129// ----------------------------------------------------------------------------
130// Copyright 2020 Bloomberg Finance L.P.
131//
132// Licensed under the Apache License, Version 2.0 (the "License");
133// you may not use this file except in compliance with the License.
134// You may obtain a copy of the License at
135//
136// http://www.apache.org/licenses/LICENSE-2.0
137//
138// Unless required by applicable law or agreed to in writing, software
139// distributed under the License is distributed on an "AS IS" BASIS,
140// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
141// See the License for the specific language governing permissions and
142// limitations under the License.
143// ----------------------------- END-OF-FILE ----------------------------------
144
145/** @} */
146/** @} */
147/** @} */
#define BSLS_EXCEPTION_VIRTUAL_NOTHROW
Definition bsls_exceptionutil.h:402
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:632
#define BSLS_KEYWORD_OVERRIDE
Definition bsls_keyword.h:653
Definition bdlb_printmethods.h:283
Definition bdldfp_decimal.h:5188