Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

std::is_copy_constructible::value is always true for variant<Ts...>

Open
#151 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
backend

Research direction

Start by reviewing the variant implementation's special member constructors and the linked Stack Overflow solution; the issue names no source file or test. Determine whether copy and move type traits correctly reflect non-copyable alternatives without unwanted side effects, then verify the resulting behavior with focused coverage.

Written by the indexing model from the issue text.

Description

The copy constructor only actually compiles when all member types are copyable, as it should. However, when checking whether the variant type is copy-constructible via SFINAE, e.g. with std::is_copy_constructible, you will always get true, because the copy constructor always exists, whether or not it is valid. The same applies to move constructors, and copy / move assignment operators.

I first thought I could fix this with a simple enable_if on each of the methods, but as it turns out I can't because if you make templates out of any of these special methods, they are not those special methods anymore. I did find a solution on StackOverflow, though I'm not entirely certain if it might introduce unwanted side effects. Could you have a look? In case it seems unproblematic to you, I would be happy to try implementing it here.

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

Getting set up

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.

More from mapbox/variant

All issues in mapbox/variant

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.