Skip to content

Commit d4cc442

Browse files
committed
improve landing pages
1 parent 3e2454d commit d4cc442

File tree

5 files changed

+339
-34
lines changed

5 files changed

+339
-34
lines changed

README.adoc

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
[cols="^1,1,1,1,1,1,1", options="header"]
2+
|===
3+
| Branch | GH Actions | Coverity Scan | codecov.io | Deps | Docs | Tests
4+
5+
| https://github.com/boostorg/openmethod/tree/master[`master`]
6+
| image:https://github.com/boostorg/openmethod/actions/workflows/ci.yml/badge.svg?branch=master[CI,link=https://github.com/boostorg/openmethod/actions/workflows/ci.yml]
7+
| image:https://scan.coverity.com/projects/32486/badge.svg[Coverity Scan Build Status,link=https://scan.coverity.com/projects/boostorg-openmethod]
8+
| image:https://codecov.io/gh/boostorg/openmethod/branch/master/graph/badge.svg[codecov,link=https://codecov.io/gh/boostorg/openmethod/branch/master]
9+
| image:https://img.shields.io/badge/deps-master-brightgreen.svg[Deps,link=https://pdimov.github.io/boostdep-report/master/openmethod.html]
10+
| image:https://img.shields.io/badge/docs-master-brightgreen.svg[Documentation,link=https://www.boost.org/doc/libs/master/libs/openmethod/doc/html/openmethod.html]
11+
| image:https://img.shields.io/badge/matrix-master-brightgreen.svg[Enter the Matrix,link=http://www.boost.org/development/tests/master/developer/openmethod.html]
12+
13+
| https://github.com/boostorg/openmethod/tree/develop[`develop`]
14+
| image:https://github.com/boostorg/openmethod/actions/workflows/ci.yml/badge.svg?branch=develop[CI,link=https://github.com/boostorg/openmethod/actions/workflows/ci.yml]
15+
| image:https://scan.coverity.com/projects/32486/badge.svg[Coverity Scan Build Status,link=https://scan.coverity.com/projects/boostorg-openmethod]
16+
| image:https://codecov.io/gh/boostorg/openmethod/branch/develop/graph/badge.svg[codecov,link=https://codecov.io/gh/boostorg/openmethod/branch/develop]
17+
| image:https://img.shields.io/badge/deps-develop-brightgreen.svg[Deps,link=https://pdimov.github.io/boostdep-report/develop/openmethod.html]
18+
| image:https://img.shields.io/badge/docs-develop-brightgreen.svg[Documentation,link=https://www.boost.org/doc/libs/develop/libs/openmethod/doc/html/openmethod.html]
19+
| image:https://img.shields.io/badge/matrix-develop-brightgreen.svg[Enter the Matrix,link=http://www.boost.org/development/tests/develop/developer/openmethod.html]
20+
|===
21+
22+
== Boost.OpenMethod
23+
24+
=== Overview
25+
26+
Boost.OpenMethod implements open-(multi-)methods in C++17 and above.
27+
Open-methods are virtual functions that exist outside of classes, as
28+
free-standing functions. This allows defining new methods for existing
29+
classes without modifying their definition, and even for classes defined in
30+
third-party libraries. Open-methods support both single and multiple dispatch.
31+
32+
=== Example
33+
34+
[source,c++]
35+
----
36+
// library
37+
38+
struct Matrix {
39+
virtual ~Matrix() = default;
40+
};
41+
42+
struct SquareMatrix : Matrix {};
43+
struct SymmetricMatrix : Matrix {};
44+
struct DiagonalMatrix : SymmetricMatrix {};
45+
46+
// application
47+
48+
#include <iostream>
49+
#include <memory>
50+
#include <vector>
51+
52+
#include <boost/openmethod.hpp>
53+
#include <boost/openmethod/initialize.hpp>
54+
55+
using boost::openmethod::virtual_ptr;
56+
57+
BOOST_OPENMETHOD_CLASSES(Matrix, SquareMatrix, SymmetricMatrix, DiagonalMatrix);
58+
59+
BOOST_OPENMETHOD(to_json, (virtual_ptr<const Matrix>, std::ostream& os), void);
60+
61+
BOOST_OPENMETHOD_OVERRIDE(
62+
to_json, (virtual_ptr<const SquareMatrix>, std::ostream& os), void) {
63+
os << "all the elements\n";
64+
}
65+
66+
BOOST_OPENMETHOD_OVERRIDE(
67+
to_json, (virtual_ptr<const SymmetricMatrix>, std::ostream& os), void) {
68+
os << "elements above and including the diagonal\n";
69+
}
70+
71+
BOOST_OPENMETHOD_OVERRIDE(
72+
to_json, (virtual_ptr<const DiagonalMatrix>, std::ostream& os), void) {
73+
os << "just the diagonal\n";
74+
}
75+
76+
int main() {
77+
std::array<std::unique_ptr<Matrix>, 3> matrices = {
78+
std::make_unique<SquareMatrix>(),
79+
std::make_unique<SymmetricMatrix>(),
80+
std::make_unique<DiagonalMatrix>(),
81+
};
82+
83+
boost::openmethod::initialize();
84+
85+
for (const auto& m : matrices) {
86+
to_json(*m, std::cout);
87+
}
88+
}
89+
90+
// output:
91+
// all the elements
92+
// elements above and including the diagonal
93+
// just the diagonal
94+
----
95+
96+
=== Features
97+
98+
* Single dispatch can be as fast as equivalent virtual function calls.
99+
100+
* Multiple dispatch in constant time (for a given number of virtual parameters).
101+
102+
* Redundancy-free multiple dispatch tables.
103+
104+
* Inter-operation with standard smart pointers, extensible to other pointer-like
105+
types.
106+
107+
* Exception agnostic by default.
108+
109+
* Macro-based interface for convenience.
110+
111+
* Macro-free interface for inter-operation with templates.
112+
113+
* Customization points for alternative RTTI systems, error handling, vptr
114+
placement, etc.
115+
116+
* Headers-only.
117+
118+
=== Requirements
119+
120+
The library requires an optimizing compiler supporting C++17 or above.
121+
122+
=== Tested Compilers
123+
124+
Boost.OpenMethod is tested with the following compilers:
125+
126+
* clang: 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
127+
128+
* gcc: 8, 9, 10, 11, 12, 13, 14, 15
129+
130+
* msvc: 14.3
131+
132+
* icpx
133+
134+
and on the following platforms:
135+
136+
* Linux
137+
138+
* macOS
139+
140+
* Windows
141+
142+
* s390x
143+
144+
=== Quality Assurance
145+
146+
The development infrastructure for the library includes these per-commit
147+
analyses:
148+
149+
* Coverage reports
150+
151+
* Clang sanitizers
152+
153+
* Compilation and tests on Drone.io and GitHub Actions
154+
155+
=== Acknowledgments
156+
157+
I would like to thank the C++ Alliance for their support, in particular
158+
Joaquín M. López Muñoz for encouraging me to submit my library and being the
159+
first to endorse it; and Dmitryi Arkhipov for volunteering to be the review
160+
manager.
161+
162+
Thanks to the members of the Boost community who posted a formal review:
163+
164+
* Andrzej Krzemienski
165+
166+
* Christian Mazakas
167+
168+
* Joaquin M López Muñoz
169+
170+
* Klemens Morgenstern
171+
172+
* Ruben Perez
173+
174+
* Yannick Le Goc
175+
176+
Also thanks to Steven Watanabe for his cogent feedback and advice, and all
177+
the people who posted remarks and suggestions.
178+
179+
This work was strongly influenced by the following papers:
180+
181+
* https://www.stroustrup.com/multimethods.pdf[Open Multi-Methods for C++],
182+
Peter Pirkelbauer, Yuriy Solodkyy and Bjarne Stroustrup
183+
184+
* https://core.ac.uk/download/pdf/18599789.pdf[Simplifying the Analysis of
185+
C++ Programs], Yuriy Solodkyy.
186+
187+
* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2216.pdf[Report
188+
on language support for Multi-Methods and Open-Methods for C++], Peter
189+
Pirkelbauer, Yuriy Solodkyy and Bjarne Stroustrup.
190+
191+
* https://dl.acm.org/doi/abs/10.1145/191081.191117[Optimizing multi-method
192+
dispatch using compressed dispatch tables], Eric Amiel, Olivier Gruber and
193+
Eric Simon.
194+
195+
Finally, thanks to Prof. J.D. Garcia, of the Universidad Carlos III in Madrid,
196+
for organizing the "using std::cpp" conference, and introducing me to Joaquín.
197+
198+
=== More information
199+
200+
* http://stackoverflow.com/questions/ask?tags=c%2B%2B,boost,boost-openmethod[Ask questions]
201+
* https://github.com/boostorg/openmethod/issues[Report bugs]: Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
202+
* Submit your patches as pull requests against *develop* branch. Note that by submitting patches you agree to license your modifications under the http://www.boost.org/LICENSE_1_0.txt[Boost Software License, Version 1.0].
203+
* Discussions about the library are held on the http://www.boost.org/community/groups.html#main[Boost developers mailing list]. Be sure to read the http://www.boost.org/community/policy.html[discussion policy] before posting and add the `[openmethod]` tag at the beginning of the subject line.
204+
205+
=== License
206+
207+
Distributed under the http://www.boost.org/LICENSE_1_0.txt[Boost Software License, Version 1.0].

README.md

Lines changed: 0 additions & 31 deletions
This file was deleted.

doc/library-detail.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../README.adoc
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// library
2+
3+
struct Matrix {
4+
virtual ~Matrix() = default;
5+
};
6+
7+
struct SquareMatrix : Matrix {};
8+
struct SymmetricMatrix : Matrix {};
9+
struct DiagonalMatrix : SymmetricMatrix {};
10+
11+
// application
12+
13+
#include <iostream>
14+
#include <memory>
15+
#include <vector>
16+
17+
#include <boost/openmethod.hpp>
18+
#include <boost/openmethod/initialize.hpp>
19+
20+
using boost::openmethod::virtual_ptr;
21+
22+
BOOST_OPENMETHOD_CLASSES(Matrix, SquareMatrix, SymmetricMatrix, DiagonalMatrix);
23+
24+
BOOST_OPENMETHOD(to_json, (virtual_ptr<const Matrix>, std::ostream& os), void);
25+
26+
BOOST_OPENMETHOD_OVERRIDE(
27+
to_json, (virtual_ptr<const SquareMatrix>, std::ostream& os), void) {
28+
os << "all the elements\n";
29+
}
30+
31+
BOOST_OPENMETHOD_OVERRIDE(
32+
to_json, (virtual_ptr<const SymmetricMatrix>, std::ostream& os), void) {
33+
os << "elements above and including the diagonal\n";
34+
}
35+
36+
BOOST_OPENMETHOD_OVERRIDE(
37+
to_json, (virtual_ptr<const DiagonalMatrix>, std::ostream& os), void) {
38+
os << "just the diagonal\n";
39+
}
40+
41+
int main() {
42+
std::array<std::unique_ptr<Matrix>, 3> matrices = {
43+
std::make_unique<SquareMatrix>(),
44+
std::make_unique<SymmetricMatrix>(),
45+
std::make_unique<DiagonalMatrix>(),
46+
};
47+
48+
boost::openmethod::initialize();
49+
50+
for (const auto& m : matrices) {
51+
to_json(*m, std::cout);
52+
}
53+
}
54+
55+
// output:
56+
// all the elements
57+
// elements above and including the diagonal
58+
// just the diagonal

doc/modules/ROOT/pages/index.adoc

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,81 @@
11
:example: ../examples
22

33
[#boost-openmethod]
4-
= Boost.OpenMethod
4+
== Boost.OpenMethod
5+
6+
=== Overview
57

68
Boost.OpenMethod implements open-(multi-)methods in C++17 and above.
9+
Open-methods are virtual functions that exist outside of classes, as
10+
free-standing functions. This allows defining new methods for existing
11+
classes without modifying their definition, and even for classes defined in
12+
third-party libraries. Open-methods support both single and multiple dispatch.
13+
14+
=== Example
15+
16+
[source,c++]
17+
----
18+
// library
19+
20+
struct Matrix {
21+
virtual ~Matrix() = default;
22+
};
23+
24+
struct SquareMatrix : Matrix {};
25+
struct SymmetricMatrix : Matrix {};
26+
struct DiagonalMatrix : SymmetricMatrix {};
27+
28+
// application
29+
30+
#include <iostream>
31+
#include <memory>
32+
#include <vector>
33+
34+
#include <boost/openmethod.hpp>
35+
#include <boost/openmethod/initialize.hpp>
36+
37+
using boost::openmethod::virtual_ptr;
38+
39+
BOOST_OPENMETHOD_CLASSES(Matrix, SquareMatrix, SymmetricMatrix, DiagonalMatrix);
40+
41+
BOOST_OPENMETHOD(to_json, (virtual_ptr<const Matrix>, std::ostream& os), void);
42+
43+
BOOST_OPENMETHOD_OVERRIDE(
44+
to_json, (virtual_ptr<const SquareMatrix>, std::ostream& os), void) {
45+
os << "all the elements\n";
46+
}
47+
48+
BOOST_OPENMETHOD_OVERRIDE(
49+
to_json, (virtual_ptr<const SymmetricMatrix>, std::ostream& os), void) {
50+
os << "elements above and including the diagonal\n";
51+
}
52+
53+
BOOST_OPENMETHOD_OVERRIDE(
54+
to_json, (virtual_ptr<const DiagonalMatrix>, std::ostream& os), void) {
55+
os << "just the diagonal\n";
56+
}
57+
58+
int main() {
59+
std::array<std::unique_ptr<Matrix>, 3> matrices = {
60+
std::make_unique<SquareMatrix>(),
61+
std::make_unique<SymmetricMatrix>(),
62+
std::make_unique<DiagonalMatrix>(),
63+
};
64+
65+
boost::openmethod::initialize();
66+
67+
for (const auto& m : matrices) {
68+
to_json(*m, std::cout);
69+
}
70+
}
71+
72+
// output:
73+
// all the elements
74+
// elements above and including the diagonal
75+
// just the diagonal
76+
----
777

8-
== Features
78+
=== Features
979

1080
* Single dispatch can be as fast as equivalent virtual function calls.
1181

@@ -27,7 +97,7 @@ Boost.OpenMethod implements open-(multi-)methods in C++17 and above.
2797

2898
* Headers-only.
2999

30-
== Requirements
100+
=== Requirements
31101

32102
The library requires an optimizing compiler supporting C++17 or above.
33103

0 commit comments

Comments
 (0)