parser::parser

## `parser::parser`

Constructors.

### Synopsis

    parser() noexcept; (1)

    explicit
    parser(
        storage_ptr sp) noexcept; (2)

    parser(
        storage_ptr sp,
        parse_options const& opt) noexcept; (3)

    parser(
        storage_ptr sp,
        parse_options const& opt,
        unsigned char* buffer,
        std::size_t size) noexcept; (4)

    template<
        std::size_t N>
    parser(
        storage_ptr sp,
        parse_options const& opt,
        unsigned char (&buffer) [N]) noexcept; (5)

    parser(
        storage_ptr sp,
        parse_options const& opt,
        std::byte* buffer,
        std::size_t size) noexcept; (6)

    template<
        std::size_t N>
    parser(
        storage_ptr sp,
        parse_options const& opt,
        std::byte (&buffer) [N]) noexcept; (7)

    parser(
        parser const&) = delete; (8)

### Description

Construct a new parser.

The parser will only support standard JSON if overloads (1) or (2) are used. Otherwise the parser will support extensions specified by the parameter `opt`.

The parsed value will use the default memory resource for storage. To use a different resource, call `reset` after construction.

The main difference between the overloads is in what the constructed parser will use for temporary storage:

- (1) the constructed parser uses the default memory resource for temporary storage.

- (2), (3) the constructed parser uses the memory resource of `sp` for temporary storage.

- (4), (6) the constructed parser first uses the caller-owned storage `[buffer, buffer + size)` for temporary storage, falling back to the memory resource of `sp` if needed.

- (5), (7) the constructed parser first uses the caller-owned storage `[buffer, buffer + N)` for temporary storage, falling back to the memory resource of `sp` if needed.

| Ownership of `buffer` is not transferred. The caller is responsible for ensuring the lifetime of the storage pointed to by `buffer` extends until the parser is destroyed.

Overload (8) is the copy constructor. The type is neither copyable nor movable, so the overload is deleted.

### Complexity

Constant.

### Exception Safety

No-throw guarantee.

### Template Parameters

Type | Description
--- | ---
`N` | The number of valid bytes in `buffer`.

### Parameters

Name | Description
--- | ---
`sp` | The memory resource to use for temporary storage.
`opt` | The parsing options to use.
`buffer` | A pointer to valid storage.
`size` | The number of valid bytes in `buffer`.

Edit this page