mirror of
https://github.com/boostorg/core.git
synced 2025-05-09 23:03:54 +00:00
Write test for empty_value private inheritance
This commit is contained in:
parent
e22bd49fa7
commit
d01b4e94cc
@ -226,6 +226,7 @@ run empty_value_test.cpp ;
|
|||||||
run empty_value_size_test.cpp ;
|
run empty_value_size_test.cpp ;
|
||||||
run empty_value_final_test.cpp ;
|
run empty_value_final_test.cpp ;
|
||||||
run empty_value_constexpr_test.cpp ;
|
run empty_value_constexpr_test.cpp ;
|
||||||
|
compile-fail empty_value_compile_fail_casting.cpp ;
|
||||||
|
|
||||||
run quick_exit_test.cpp ;
|
run quick_exit_test.cpp ;
|
||||||
run-fail quick_exit_fail.cpp ;
|
run-fail quick_exit_fail.cpp ;
|
||||||
|
20
test/empty_value_compile_fail_casting.cpp
Normal file
20
test/empty_value_compile_fail_casting.cpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright 2024 Braden Ganetsky
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/core/empty_value.hpp>
|
||||||
|
|
||||||
|
struct empty {};
|
||||||
|
|
||||||
|
// This test ensures private inheritance of `boost::empty_value<T>` for empty `T`.
|
||||||
|
// With public inheritance, `boost::empty_value<empty>*` could cast to `empty*`.
|
||||||
|
void test_empty_not_convertible_to_base()
|
||||||
|
{
|
||||||
|
const boost::empty_value<empty> x(boost::empty_init);
|
||||||
|
const empty* x2 = static_cast<const empty*>(&x);
|
||||||
|
(void)x2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user