Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
f9aacc6
BOOST_OPENMETHOD_DETAIL_HAS_STATIC_FN
jll63 Jan 26, 2026
1eb22d8
inter-operate with 'any'
jll63 Feb 28, 2026
f0aafd3
inter-operate with 'any'
jll63 Mar 7, 2026
4b00b38
Merge branch 'develop' into feature/any
jll63 Jul 28, 2026
22f74cf
doc: document macros with MrDocs
jll63 Jul 30, 2026
607b462
doc: link the registry macro pages back to the guide
jll63 Jul 30, 2026
b2dcdb8
doc: add See Also guide links to the macro reference pages
jll63 Jul 30, 2026
3a1fbc1
Merge branch 'develop' into feature/any
jll63 Jul 30, 2026
a1746d3
doc: make base-url a real Antora attribute
jll63 Jul 31, 2026
2a8e394
doc: tidy the registries and shared libraries pages
jll63 Jul 31, 2026
92a87e3
doc: guide links on every reference page, via a template override
jll63 Jul 31, 2026
8a69196
doc: render See Also as one comma-separated list
jll63 Jul 31, 2026
2fd58dd
doc: restore mrdocs.yml from a trap, not at the end of the build
jll63 Jul 31, 2026
c09d995
doc: make the Reference nav entry a link
jll63 Jul 31, 2026
4914053
support std::any by mutable and xvalue reference
jll63 Jul 31, 2026
810a981
support boost::any
jll63 Jul 31, 2026
b284384
doc: include compiled snippets in reference doc comments
jll63 Aug 1, 2026
80e8157
doc: convert the virtual_ptr examples to include: markers
jll63 Aug 1, 2026
2efb550
doc: fix the prose around the virtual_ptr multi-example blocks
jll63 Aug 1, 2026
bfcb4de
doc: examples for unique_ptr and for the smart-pointer interop headers
jll63 Aug 1, 2026
bf7656c
doc: make the factory examples call a method
jll63 Aug 1, 2026
b8fc944
doc: examples for the policies headers
jll63 Aug 1, 2026
b6512b7
doc: convert the last convertible @code blocks
jll63 Aug 1, 2026
c3d9def
doc: document that a registry is its policy list, not its class
jll63 Aug 1, 2026
d489397
doc: a usage example for BOOST_OPENMETHOD
jll63 Aug 1, 2026
33f2bbf
doc: a usage example for BOOST_OPENMETHOD_OVERRIDE
jll63 Aug 1, 2026
202b350
doc: point BOOST_OPENMETHOD at the overrider example rather than repe…
jll63 Aug 1, 2026
4c1dfe0
doc: examples for BOOST_OPENMETHOD_CLASSES, correct and not
jll63 Aug 1, 2026
f086985
type_vptr -> vptr
jll63 Aug 2, 2026
fcc7bdc
doc: an example for BOOST_OPENMETHOD_INLINE_OVERRIDE
jll63 Aug 1, 2026
27b06e6
doc: examples for BOOST_OPENMETHOD_DECLARE_OVERRIDER and _DEFINE_OVER…
jll63 Aug 2, 2026
51e2355
doc: an example for BOOST_OPENMETHOD_ENABLE_RUNTIME_CHECKS
jll63 Aug 2, 2026
7414b78
doc: the initialize report example checks and bails, as a program would
jll63 Aug 2, 2026
58c0fa8
doc: error examples show the mistake, not the harness
jll63 Aug 2, 2026
e375b19
doc: harness out of every snippet, registry out of the error ones
jll63 Aug 2, 2026
992a2f2
doc: elided overrider bodies read as a comment, not a block comment
jll63 Aug 2, 2026
6640077
update comment
jll63 Aug 2, 2026
9a9ce1d
doc: wrap an over-long comment in the BOOST_OPENMETHOD_CLASSES example
jll63 Aug 2, 2026
deb5154
doc: put the final_virtual_ptr example on the overload people call
jll63 Aug 2, 2026
24c2314
doc: "known exact class", not "known dynamic type"
jll63 Aug 2, 2026
a4b84b0
doc: say why final_virtual_ptr exists
jll63 Aug 2, 2026
7ecd96c
dynamic_vptr -> vptr
jll63 Aug 8, 2026
65cd1b5
fix leftovers of the dynamic_vptr -> vptr rename
jll63 Aug 8, 2026
57b6c32
add virtual_any
jll63 Aug 8, 2026
78143c8
fix infinite recursion in virtual_any's vptr friend on MSVC
jll63 Aug 8, 2026
01c863d
Merge branch 'feature/mrdocs-macros' into feature/any
jll63 Aug 8, 2026
9dcba28
doc: an Interoperation page, and reference examples for the `any`s
jll63 Aug 8, 2026
8bcb1a3
alias use_std_any_types and use_boost_any_types
jll63 Aug 8, 2026
50d5ec9
support catch-all overriders on plain `any` virtual parameters
jll63 Aug 8, 2026
ff11651
doc: lead the Interoperation page with `virtual_`, not `virtual_any`
jll63 Aug 8, 2026
acdd8e0
test: make the virtual_any-by-value compile-fail test actually fail o…
jll63 Aug 8, 2026
e946dd2
doc: fix the broken `any` header links on the Headers page
jll63 Aug 8, 2026
f1d3cd8
doc: narrow the Interoperation page to `any`
jll63 Aug 8, 2026
22aad40
doc: remove base-url dance
jll63 Aug 9, 2026
3bedb21
doc: document `vptr` in VirtualTraits and VptrFn
jll63 Aug 9, 2026
f77e3c8
doc: make the header links follow the deployment
jll63 Aug 9, 2026
608f1b6
Merge branch 'feature/mrdocs-macros' into feature/any
jll63 Aug 9, 2026
a735c45
doc: make the `any` header links follow the deployment too
jll63 Aug 9, 2026
65904e3
doc: inline the final_virtual_ptr example instead of linking to it
jll63 Aug 9, 2026
1fc8ea3
doc: hide the deleted `final_virtual_ptr` overloads from the reference
jll63 Aug 9, 2026
437c666
reject virtual_ptr over classes with a boost_openmethod_vptr overload
jll63 Aug 9, 2026
516606c
doc: trim the any-interop entries on the Headers page
jll63 Aug 9, 2026
69b5d43
remove the make_*_virtual factories
jll63 Aug 9, 2026
df3c0b7
add virtual_any_ref, a non-owning counterpart of virtual_any
jll63 Aug 9, 2026
cb44af6
test: exercise virtual_any_ref with boost::any
jll63 Aug 10, 2026
8845d1c
doc: point the header links at GitHub
jll63 Aug 10, 2026
8b21152
Merge branch 'feature/mrdocs-macros' into feature/any
jll63 Aug 10, 2026
9221d15
doc: point the `any` header links at GitHub too
jll63 Aug 10, 2026
34a2a3f
doc: drop $meta when copying doc nodes in the include extension
jll63 Aug 10, 2026
b45feb4
Merge branch 'feature/mrdocs-macros' into feature/any
jll63 Aug 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ set(

if (BOOST_OPENMETHOD_BUILD_TESTS OR BOOST_OPENMETHOD_MRDOCS_BUILD)
list(APPEND BOOST_OPENMETHOD_DEPENDENCIES Boost::smart_ptr)
list(APPEND BOOST_OPENMETHOD_DEPENDENCIES Boost::any)
endif()

foreach (BOOST_OPENMETHOD_DEPENDENCY ${BOOST_OPENMETHOD_DEPENDENCIES})
Expand Down Expand Up @@ -219,5 +220,7 @@ if (BOOST_OPENMETHOD_BUILD_TESTS)
# Examples
if (BOOST_OPENMETHOD_BUILD_EXAMPLES)
add_subdirectory(doc/modules/ROOT/examples)
# Sources behind the `include:` markers in the reference doc comments.
add_subdirectory(doc/modules/ROOT/snippets)
endif ()
endif ()
6 changes: 6 additions & 0 deletions doc/antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ asciidoc:
attributes:
source-language: asciidoc@
table-caption: false
# Base of the links to the header sources in ref_headers.adoc. It must be
# an absolute url: neither the PR previews nor boost.org serve the library
# sources next to the docs. The previews publish libs/openmethod/doc only,
# and boost.org serves the headers from doc/libs/<version>/boost, not from
# libs/openmethod/include.
headers-url: https://github.com/boostorg/openmethod/blob/develop/include
nav:
- modules/ROOT/nav.adoc
ext:
Expand Down
72 changes: 2 additions & 70 deletions doc/build_antora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,82 +22,14 @@ fi
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd "$SCRIPT_DIR"

if [ -z "${BOOST_SRC_DIR:-}" ]; then
CANDIDATE=$( cd "$SCRIPT_DIR/../../.." 2>/dev/null && pwd )
if [ -n "$CANDIDATE" ]; then
BOOST_SRC_DIR_IS_VALID=ON
for F in "CMakeLists.txt" "Jamroot" "boost-build.jam" "bootstrap.sh" "libs"; do
if [ ! -e "$CANDIDATE/$F" ]; then
BOOST_SRC_DIR_IS_VALID=OFF
break
fi
done
if [ "$BOOST_SRC_DIR_IS_VALID" = "ON" ]; then
export BOOST_SRC_DIR="$CANDIDATE"
echo "Using BOOST_SRC_DIR=$BOOST_SRC_DIR"
fi
fi
fi

BRANCH=master

if [ -n "${BOOST_SRC_DIR:-}" ]; then
if [ -n "${CIRCLE_REPOSITORY_URL:-}" ]; then
if [[ "$CIRCLE_REPOSITORY_URL" =~ boostorg/boost(\.git)?$ ]]; then
LIB="$(basename "$(dirname "$SCRIPT_DIR")")"
REPOSITORY="boostorg/${LIB}"
BRANCH=$(git -C "$BOOST_SRC_DIR" rev-parse --abbrev-ref HEAD)
else
ACCOUNT="${CIRCLE_REPOSITORY_URL#*:}"
ACCOUNT="${ACCOUNT%%/*}"
LIB=$(basename "$(git rev-parse --show-toplevel)")
REPOSITORY="${ACCOUNT}/${LIB}"
fi
SHA=$(git -C "$BOOST_SRC_DIR/libs" ls-tree HEAD | grep -w openmethod | awk '{print $3}')
elif [ -n "${GITHUB_REPOSITORY:-}" ]; then
REPOSITORY="${GITHUB_REPOSITORY}"
SHA="${GITHUB_SHA}"
fi
fi

cd "$SCRIPT_DIR"

if [ -n "${REPOSITORY}" ] && [ -n "${SHA}" ]; then
BASE_URL="https://github.com/${REPOSITORY}/blob/${SHA}"
echo "Setting base-url to $BASE_URL"
cp mrdocs.yml mrdocs.yml.bak
perl -i -pe 's{^\s*base-url:.*$}{base-url: '"$BASE_URL/"'}' mrdocs.yml
else
echo "REPOSITORY or SHA not set; skipping base-url modification"
fi

echo "Building documentation with Antora..."

echo "Installing npm dependencies..."
npm ci

echo "Building docs in custom dir..."
PATH="$(pwd)/node_modules/.bin:${PATH}"
export PATH
npx antora --clean --fetch "$PLAYBOOK" --stacktrace # --log-level all

echo "Fixing links to non-mrdocs URIs..."
echo "BRANCH='${BRANCH:-}'"
echo "BASE_URL='${BASE_URL:-}'"

for f in $(find html -name '*.html'); do
perl -i -pe "s{&lcub;&lcub;(.*?)&rcub;&rcub;}{<a href=\"../../../\$1.html\">\$1</a>}g" "$f"
perl -i -pe "s{<a href=\"motivation.html\">Boost.OpenMethod</a>}{<a href=\"https://www.boost.org/library/${BRANCH}/openmethod/\">Boost.OpenMethod</a>}g" "$f"
done

if [ -n "${BASE_URL:-}" ]; then
if [ -f mrdocs.yml.bak ]; then
mv -f mrdocs.yml.bak mrdocs.yml
echo "Restored original mrdocs.yml"
else
echo "mrdocs.yml.bak not found; skipping restore"
fi
perl -i -pe "s[{{BASE_URL}}][$BASE_URL]g" \
html/openmethod/ref_headers.html html/openmethod/BOOST_OPENMETHOD*.html
fi
npx antora --clean --fetch "$PLAYBOOK" --stacktrace --log-level all

echo "Done"
55 changes: 55 additions & 0 deletions doc/modules/ROOT/examples/registry_identity.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// 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)

#include <cassert>
#include <type_traits>

#include <boost/openmethod.hpp>
#include <boost/openmethod/policies/vptr_map.hpp>

using namespace boost::openmethod;

namespace same_policies {

// tag::shared[]
struct animals : registry<policies::std_rtti, policies::vptr_map<>> {};
struct vehicles : registry<policies::std_rtti, policies::vptr_map<>> {};

// the policy lists are identical, so this is one registry, not two
static_assert(std::is_same_v<animals::registry_type, vehicles::registry_type>);
// end::shared[]

} // namespace same_policies

namespace distinct_policies {

// tag::distinct[]
// a policy in a category of its own, carrying nothing but a number
struct marker_category {
using category = marker_category;
};

template<int N>
struct marker final : marker_category {
template<class Registry>
struct fn {};
};

struct animals : default_registry::with<marker<1>> {};
struct vehicles : default_registry::with<marker<2>> {};

static_assert(!std::is_same_v<animals::registry_type, vehicles::registry_type>);
// end::distinct[]

} // namespace distinct_policies

auto main() -> int {
// the shared pair reach one state, the distinct pair two
assert(same_policies::animals::id() == same_policies::vehicles::id());
assert(
distinct_policies::animals::id() != distinct_policies::vehicles::id());

return 0;
}
63 changes: 63 additions & 0 deletions doc/modules/ROOT/examples/virtual_any.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright (c) 2018-2026 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)

// clang-format off

// tag::content[]
#include <any>
#include <iostream>
#include <string>

#include <boost/openmethod.hpp>
#include <boost/openmethod/interop/std_any.hpp>

using namespace boost::openmethod;

struct Dog {
std::string name;
};

// `std::any` becomes the common base of the types it may contain.
BOOST_OPENMETHOD_REGISTER(use_std_any_types<Dog, std::string, int, float>);

BOOST_OPENMETHOD(name, (virtual_<const std::any&>), std::string);

// An overrider takes the contained value...
BOOST_OPENMETHOD_OVERRIDE(name, (const Dog& dog), std::string) {
return dog.name + " the dog";
}

BOOST_OPENMETHOD_OVERRIDE(name, (const std::string& name), std::string) {
return name;
}

BOOST_OPENMETHOD_OVERRIDE(name, (const int& value), std::string) {
return std::to_string(value) + " the integer";
}

// ...or the `any` itself, which makes it a catch-all.
BOOST_OPENMETHOD_OVERRIDE(name, (const std::any&), std::string) {
return "something else";
}

#include <boost/openmethod/initialize.hpp>

int main() {
initialize();

std::any spot = Dog{"Spot"};
std::any felix = std::string("Felix the cat");
std::any answer = 42;
std::any pi = 3.14f;

std::cout << name(spot) << "\n"; // Spot the dog
std::cout << name(felix) << "\n"; // Felix the cat
std::cout << name(answer) << "\n"; // 42 the integer

// `float` is registered, but has no overrider of its own, so the
// catch-all applies.
std::cout << name(pi) << "\n"; // something else
}
// end::content[]
3 changes: 2 additions & 1 deletion doc/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
** xref:custom_rtti.adoc[Custom RTTI]
** xref:error_handling.adoc[Error Handling]
** xref:virtual_ptr_alt.adoc[Virtual Pointer Alternatives]
** xref:interop_any.adoc[Interoperation with `any`]
** xref:shared_libraries.adoc[Shared Libraries]
* Reference
* xref:reference:index.adoc[Reference]
** xref:ref_headers.adoc[Headers]
** xref:ref_macros.adoc[Macros]
** xref:reference:boost/openmethod.adoc[Namespace boost::openmethod]
Expand Down
87 changes: 0 additions & 87 deletions doc/modules/ROOT/pages/BOOST_OPENMETHOD.adoc

This file was deleted.

20 changes: 0 additions & 20 deletions doc/modules/ROOT/pages/BOOST_OPENMETHOD_CLASSES.adoc

This file was deleted.

Loading
Loading