Skip to content

Commit

Permalink
Document module support.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzmaddock committed Dec 18, 2024
1 parent c898c51 commit 7e23c2b
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 6 deletions.
6 changes: 3 additions & 3 deletions doc/html/boost_regex/install.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="home" href="../index.html" title="Boost.Regex 7.0.1">
<link rel="up" href="../index.html" title="Boost.Regex 7.0.1">
<link rel="prev" href="configuration/tuning.html" title="Algorithm Tuning">
<link rel="next" href="intro.html" title="Introduction and Overview">
<link rel="next" href="modules.html" title="Module Support (Experimental)">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
Expand All @@ -21,7 +21,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="configuration/tuning.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="intro.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="configuration/tuning.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="modules.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
Expand Down Expand Up @@ -109,7 +109,7 @@ <h5>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="configuration/tuning.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="intro.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="configuration/tuning.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="modules.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
6 changes: 3 additions & 3 deletions doc/html/boost_regex/intro.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="Boost.Regex 7.0.1">
<link rel="up" href="../index.html" title="Boost.Regex 7.0.1">
<link rel="prev" href="install.html" title="Building and Installing the Library">
<link rel="prev" href="modules.html" title="Module Support (Experimental)">
<link rel="next" href="unicode.html" title="Unicode and Boost.Regex">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
Expand All @@ -21,7 +21,7 @@
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="install.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="unicode.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="modules.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="unicode.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
Expand Down Expand Up @@ -206,7 +206,7 @@
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="install.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="unicode.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
<a accesskey="p" href="modules.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="unicode.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
108 changes: 108 additions & 0 deletions doc/html/boost_regex/modules.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Module Support (Experimental)</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="Boost.Regex 7.0.1">
<link rel="up" href="../index.html" title="Boost.Regex 7.0.1">
<link rel="prev" href="install.html" title="Building and Installing the Library">
<link rel="next" href="intro.html" title="Introduction and Overview">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="install.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="intro.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="boost_regex.modules"></a><a class="link" href="modules.html" title="Module Support (Experimental)">Module Support (Experimental)</a>
</h2></div></div></div>
<p>
This library has experimental support for C++ modules (C++20 or later), currently
the support is experimental not least because at the time of writing (2025)
build tools have yet to catch up with module support.
</p>
<p>
In order to use this library as a module you simply add a:
</p>
<pre class="programlisting"><span class="identifier">import</span> <span class="identifier">boost</span><span class="special">.</span><span class="identifier">regex</span><span class="special">;</span>
</pre>
<p>
to your code.
</p>
<p>
Before that you must first build the module, which consists of these steps:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
Depending on your compiler, you may need to build the standard library
module, and place the standard module somewhere that your compiler can
find it.
</li>
<li class="listitem">
Build <code class="computeroutput"><span class="identifier">libs</span><span class="special">/</span><span class="identifier">regex</span><span class="special">/</span><span class="identifier">module</span><span class="special">/</span><span class="identifier">regex</span><span class="special">.</span><span class="identifier">cxx</span></code> into the boost.regex module, and
place the module definition file somewhere that your compiler can find
it.
</li>
<li class="listitem">
Build all the source files in <code class="computeroutput"><span class="identifier">libs</span><span class="special">/</span><span class="identifier">regex</span><span class="special">/</span><span class="identifier">module</span></code>
(including regex.cxx) into a library, and place the result somewhere your
linker can find it.
</li>
</ul></div>
<p>
Visual studio users can simplify all of the above into one step, by placing
everything in <code class="computeroutput"><span class="identifier">libs</span><span class="special">/</span><span class="identifier">regex</span><span class="special">/</span><span class="identifier">module</span></code>
into a static library project, and then adding the <code class="computeroutput"><span class="special">/</span><span class="identifier">interface</span></code> command line option to the regex.cxx
source file.
</p>
<p>
Known limitations:
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
As of the start of 2025, only very recent versions of clang and msvc are
supported. GCC is definitely not supported.
</li>
<li class="listitem">
The regex library must always be consumed via <code class="computeroutput"><span class="identifier">import</span>
<span class="identifier">boost</span><span class="special">.</span><span class="identifier">regex</span><span class="special">;</span></code>
and you can never mix this with <code class="computeroutput"><span class="preprocessor">#includes</span>
<span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">regex</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>.
</li>
<li class="listitem">
Ideally the standard library should always be used via <code class="computeroutput"><span class="identifier">import</span>
<span class="identifier">std</span></code> and not via #includes: more
recent compilers are mostly making this work, but are still very fragile.
</li>
<li class="listitem">
The regex version imported, is always the "standalone" version
which includes no other Boost headers.
</li>
</ul></div>
<p>
Finally... there are some build and test scripts in <code class="computeroutput"><span class="identifier">libs</span><span class="special">/</span><span class="identifier">regex</span><span class="special">/</span><span class="identifier">test</span><span class="special">/</span><span class="identifier">module</span></code>
for msvc and clang.
</p>
</div>
<div class="copyright-footer">Copyright © 1998-2013 John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="install.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="intro.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
1 change: 1 addition & 0 deletions doc/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<dt><span class="section"><a href="boost_regex/configuration/tuning.html">Algorithm Tuning</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="boost_regex/install.html">Building and Installing the Library</a></span></dt>
<dt><span class="section"><a href="boost_regex/modules.html">Module Support (Experimental)</a></span></dt>
<dt><span class="section"><a href="boost_regex/intro.html">Introduction and Overview</a></span></dt>
<dt><span class="section"><a href="boost_regex/unicode.html">Unicode and Boost.Regex</a></span></dt>
<dt><span class="section"><a href="boost_regex/captures.html">Understanding Marked Sub-Expressions
Expand Down
40 changes: 40 additions & 0 deletions doc/modules.qbk
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[/
Copyright 2024 John Maddock.
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).
]

[section:modules Module Support (Experimental)]

This library has experimental support for C++ modules (C++20 or later), currently the support is experimental
not least because at the time of writing (2025) build tools have yet to catch up with module support.

In order to use this library as a module you simply add a:

```
import boost.regex;
```

to your code.

Before that you must first build the module, which consists of these steps:

* Depending on your compiler, you may need to build the standard library module, and place the standard module somewhere that your compiler can find it.
* Build `libs/regex/module/regex.cxx` into the boost.regex module, and place the module definition file somewhere that your compiler can find it.
* Build all the source files in `libs/regex/module` (including regex.cxx) into a library, and place the result somewhere your linker can find it.

Visual studio users can simplify all of the above into one step, by placing everything in `libs/regex/module` into a static library project, and then adding the `/interface`
command line option to the regex.cxx source file.

Known limitations:

* As of the start of 2025, only very recent versions of clang and msvc are supported. GCC is definitely not supported.
* The regex library must always be consumed via `import boost.regex;` and you can never mix this with `#includes <boost/regex.hpp>`.
* Ideally the standard library should always be used via `import std` and not via #includes: more recent compilers are mostly making this work, but are still very fragile.
* The regex version imported, is always the "standalone" version which includes no other Boost headers.

Finally... there are some build and test scripts in `libs/regex/test/module` for msvc and clang.

[endsect]

1 change: 1 addition & 0 deletions doc/regex.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ PDF version of this manual is also available].

[include configuration.qbk]
[include install.qbk]
[include modules.qbk]
[include introduction.qbk]
[include unicode.qbk]
[include captures.qbk]
Expand Down

0 comments on commit 7e23c2b

Please sign in to comment.