Provide const overload of ObjectStorage::stored_object()

Fixes #1820
This commit is contained in:
Martin Hořeňovský 2019-12-23 21:22:32 +01:00
parent 82baef62e2
commit 0f47fe16bd
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A

View File

@ -55,11 +55,15 @@ namespace Catch {
template <typename U> template <typename U>
void destruct_on_exit(typename std::enable_if<!Destruct, U>::type* = 0) { } void destruct_on_exit(typename std::enable_if<!Destruct, U>::type* = 0) { }
T& stored_object() T& stored_object() {
{
return *static_cast<T*>(static_cast<void*>(&data)); return *static_cast<T*>(static_cast<void*>(&data));
} }
T const& stored_object() const {
return *static_cast<T*>(static_cast<void*>(&data));
}
TStorage data; TStorage data;
}; };
} // namespace Detail } // namespace Detail