@@ -104,7 +104,7 @@ struct smart_holder {
104
104
bool is_populated : 1 ;
105
105
106
106
// Design choice: smart_holder is movable but not copyable.
107
- smart_holder (smart_holder &&) = default ;
107
+ smart_holder (smart_holder &&) = default ;
108
108
smart_holder (const smart_holder &) = delete ;
109
109
smart_holder &operator =(smart_holder &&) = default ;
110
110
smart_holder &operator =(const smart_holder &) = delete ;
@@ -124,8 +124,8 @@ struct smart_holder {
124
124
template <typename T>
125
125
static void ensure_pointee_is_destructible (const char *context) {
126
126
if (!std::is_destructible<T>::value)
127
- throw std::runtime_error (std::string (" Pointee is not destructible (" ) + context
128
- + " )." );
127
+ throw std::invalid_argument (std::string (" Pointee is not destructible (" ) + context
128
+ + " )." );
129
129
}
130
130
131
131
void ensure_is_populated (const char *context) const {
@@ -136,16 +136,16 @@ struct smart_holder {
136
136
137
137
void ensure_vptr_is_using_builtin_delete (const char *context) const {
138
138
if (vptr_is_external_shared_ptr) {
139
- throw std::runtime_error (std::string (" Cannot disown external shared_ptr (" ) + context
140
- + " )." );
139
+ throw std::invalid_argument (std::string (" Cannot disown external shared_ptr (" )
140
+ + context + " )." );
141
141
}
142
142
if (vptr_is_using_noop_deleter) {
143
- throw std::runtime_error (std::string (" Cannot disown non-owning holder (" ) + context
144
- + " )." );
143
+ throw std::invalid_argument (std::string (" Cannot disown non-owning holder (" ) + context
144
+ + " )." );
145
145
}
146
146
if (!vptr_is_using_builtin_delete) {
147
- throw std::runtime_error (std::string (" Cannot disown custom deleter (" ) + context
148
- + " )." );
147
+ throw std::invalid_argument (std::string (" Cannot disown custom deleter (" ) + context
148
+ + " )." );
149
149
}
150
150
}
151
151
@@ -154,34 +154,34 @@ struct smart_holder {
154
154
const std::type_info *rtti_requested = &typeid (D);
155
155
if (!rtti_uqp_del) {
156
156
if (!is_std_default_delete<T>(*rtti_requested)) {
157
- throw std::runtime_error (std::string (" Missing unique_ptr deleter (" ) + context
158
- + " )." );
157
+ throw std::invalid_argument (std::string (" Missing unique_ptr deleter (" ) + context
158
+ + " )." );
159
159
}
160
160
ensure_vptr_is_using_builtin_delete (context);
161
161
} else if (!(*rtti_requested == *rtti_uqp_del)) {
162
- throw std::runtime_error (std::string (" Incompatible unique_ptr deleter (" ) + context
163
- + " )." );
162
+ throw std::invalid_argument (std::string (" Incompatible unique_ptr deleter (" ) + context
163
+ + " )." );
164
164
}
165
165
}
166
166
167
167
void ensure_has_pointee (const char *context) const {
168
168
if (!has_pointee ()) {
169
- throw std::runtime_error (std::string (" Disowned holder (" ) + context + " )." );
169
+ throw std::invalid_argument (std::string (" Disowned holder (" ) + context + " )." );
170
170
}
171
171
}
172
172
173
173
void ensure_use_count_1 (const char *context) const {
174
174
if (vptr.get () == nullptr ) {
175
- throw std::runtime_error (std::string (" Cannot disown nullptr (" ) + context + " )." );
175
+ throw std::invalid_argument (std::string (" Cannot disown nullptr (" ) + context + " )." );
176
176
}
177
177
// In multithreaded environments accessing use_count can lead to
178
178
// race conditions, but in the context of Python it is a bug (elsewhere)
179
179
// if the Global Interpreter Lock (GIL) is not being held when this code
180
180
// is reached.
181
181
// SMART_HOLDER_WIP: IMPROVABLE: assert(GIL is held).
182
182
if (vptr.use_count () != 1 ) {
183
- throw std::runtime_error (std::string (" Cannot disown use_count != 1 (" ) + context
184
- + " )." );
183
+ throw std::invalid_argument (std::string (" Cannot disown use_count != 1 (" ) + context
184
+ + " )." );
185
185
}
186
186
}
187
187
0 commit comments