Skip to content

Commit c4f967f

Browse files
committed
more validations
1 parent 626c749 commit c4f967f

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,7 @@ openmethod_compile_fail_test(
9595
compile_fail_virtual_ptr_shared_not_const "std::shared_ptr cannot be passed by non-const lvalue reference")
9696
openmethod_compile_fail_test(
9797
compile_fail_virtual_ptr_value_to_ref "different virtual_ptr<> reference categories")
98+
openmethod_compile_fail_test(
99+
compile_fail_virtual_parameter_private_base_macros "error")
100+
openmethod_compile_fail_test(
101+
compile_fail_virtual_parameter_private_base_core "must be an unambiguous accessible base")
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) 2018-2025 Jean-Louis Leroy
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// See accompanying file LICENSE_1_0.txt
4+
// or copy at http://www.boost.org/LICENSE_1_0.txt)
5+
6+
#include <boost/openmethod.hpp>
7+
8+
using namespace boost::openmethod;
9+
10+
class Animal {
11+
public:
12+
virtual ~Animal() = default;
13+
};
14+
15+
class Cat : private Animal {
16+
public:
17+
Animal& as_animal() {
18+
return *this;
19+
}
20+
};
21+
22+
struct poke;
23+
24+
auto poke_cat(virtual_ptr<Cat>) -> void {
25+
}
26+
27+
BOOST_OPENMETHOD_REGISTER(method<poke, void(virtual_ptr<Animal>)>::override<poke_cat>);
28+
29+
30+
int main() {
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) 2018-2025 Jean-Louis Leroy
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// See accompanying file LICENSE_1_0.txt
4+
// or copy at http://www.boost.org/LICENSE_1_0.txt)
5+
6+
#include <boost/openmethod.hpp>
7+
8+
using boost::openmethod::virtual_ptr;
9+
10+
class Animal {
11+
public:
12+
virtual ~Animal() = default;
13+
};
14+
15+
class Cat : private Animal {
16+
public:
17+
Animal& as_animal() {
18+
return *this;
19+
}
20+
};
21+
22+
BOOST_OPENMETHOD(poke, (virtual_ptr<Animal&>), void);
23+
24+
BOOST_OPENMETHOD_OVERRIDE(poke, (virtual_ptr<Cat>), void) {
25+
}
26+
27+
int main() {
28+
Cat felix;
29+
poke(felix.as_animal());
30+
return 0;
31+
}

0 commit comments

Comments
 (0)