diff --git a/include/boost/json/impl/parser.ipp b/include/boost/json/impl/parser.ipp
index 1e37ead5..489a6752 100644
--- a/include/boost/json/impl/parser.ipp
+++ b/include/boost/json/impl/parser.ipp
@@ -154,7 +154,14 @@ parser::
}
parser::
-parser()
+parser() noexcept
+ : parser(storage_ptr())
+{
+}
+
+parser::
+parser(storage_ptr sp) noexcept
+ : rs_(std::move(sp))
{
lev_.st = state::need_start;
}
diff --git a/include/boost/json/parser.hpp b/include/boost/json/parser.hpp
index dfa249fb..14602cb1 100644
--- a/include/boost/json/parser.hpp
+++ b/include/boost/json/parser.hpp
@@ -56,14 +56,17 @@ namespace json {
to bound the amount of work performed in each
parsing cycle.
-
+ @par Intermediate Storage
The parser may dynamically allocate intermediate
storage as needed to accommodate the nesting level
- of the JSON being parsed. This storage is freed
- when the parser is destroyed, allowing the parser
- to cheaply re-use this memory when parsing
- subsequent JSONs, improving performance.
+ of the JSON being parsed. Intermediate storage is
+ allocated using the @ref storage_ptr passed to
+ the constructor; if no such argument is specified,
+ the default memory resource will be used instead.
+ This storage is freed when the parser is destroyed,
+ allowing the parser to cheaply reuse this memory
+ when parsing subsequent JSONs, improving performance.
*/
class parser : public basic_parser
{
@@ -98,11 +101,39 @@ public:
/** Default constructor.
+ Constructs an empty parser that uses the
+ default memory resource to allocate
+ intermediate storage.
+
+ @note
Before any JSON can be parsed, the function
- @ref start must be called.
+ @ref start must be called.
*/
BOOST_JSON_DECL
- parser();
+ parser() noexcept;
+
+ /** Constructor.
+
+ Constructs a empty parser using the supplied
+ @ref storage_ptr to allocate
+ intermediate storage.
+
+ @note
+ Before any JSON can be parsed, the function
+ @ref start must be called.
+
+
+
+ The `sp` parameter is only used to
+ allocate intermediate storage; will not be used
+ for the @ref value returned by @ref release.
+
+ @param sp The @ref storage_ptr to use for
+ intermediate storage allocations.
+ */
+ BOOST_JSON_DECL
+ explicit
+ parser(storage_ptr sp) noexcept;
/** Reserve internal storage space.