examples -> example

This commit is contained in:
Jean-Louis Leroy
2025-06-21 13:22:09 -04:00
parent 9edce6902b
commit a078c9c002
55 changed files with 161 additions and 255 deletions

31
example/dl_shared.cpp Normal file
View File

@@ -0,0 +1,31 @@
// Copyright (c) 2018-2025 Jean-Louis Leroy
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// tag::dl_shared[]
// dl_shared.cpp
#include <string>
#include <boost/openmethod.hpp>
#include "dl.hpp"
BOOST_OPENMETHOD_OVERRIDE(
encounter, (dyn_vptr<Herbivore>, dyn_vptr<Carnivore>), std::string) {
return "run\n";
}
struct Tiger : Carnivore {};
BOOST_OPENMETHOD_CLASSES(Tiger, Carnivore, dynamic_policy);
extern "C" auto make_tiger() -> Tiger* {
return new Tiger;
}
BOOST_OPENMETHOD_OVERRIDE(
encounter, (dyn_vptr<Carnivore>, dyn_vptr<Herbivore>), std::string) {
return "hunt\n";
}
// end::dl_shared[]