mapbox / mapbox/variant

Noexcept on constructor

Open
#61 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

interface change
Dominant language
C++
Stars
384
Forks
96
PR merge metrics
No merged PRs in 30d

Description

The constructor for `variant` is declared `noexcept` which is only true if the constructor for the underlying type is noexcept. Because we don't know which type that will be we can only mark the constructor noexcept if all underlying types have a noexcept constructor.

https://github.com/mapbox/variant/blob/861faa8125ae7c2d9e41e33b3d5d97a17213c415/variant.hpp#L584-L590

There is a comment `// nothrow` in there. It is unclear what it means. Maybe it was meant to say that we expect the constructor to be "nothrow", but that really must be encoded in code.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open variant.hpp at lines 584-590 and inspect the variant constructor and its underlying-type construction path. Verify the exception specification against the requirement that every possible underlying constructor is noexcept; done means the declaration is noexcept only when that condition holds.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.