microsoft / microsoft/STL

`<utility>`: Is extending triviality for `pair` and `tuple` on the list of improvements for vNext?

Open
#5,667 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

performance vNext
Dominant language
C++
Stars
11.2k
Forks
1.7k
Avg merge
4d 15h
Merged PRs (30d)
22

Description

static_assert(std::is_trivially_copy_assignable_v<std::tuple<int, int>>); // fails
static_assert(std::is_trivially_copy_constructible_v<std::tuple<int, int>>); // fails
static_assert(std::is_trivially_copy_assignable_v<std::pair<int, int>>); // fails
static_assert(std::is_trivially_copy_constructible_v<std::pair<int, int>>); // passes

Current the implementation of pair and tuple is not trivially copy constructible and assignable when their underlying types are, which I assume hinders performance and certain optimizations - which is a shame since they should be zero cost abstractions. Implementing this improvement is an obvious ABI break and I believe it would require rewriting a big chunk of the tuple implementation. I was wondering if this improvement is considered in the vNext abi break - I know tuple compresssion of empty types is, but I haven't seen any discurssion on this.

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

No implementation file or test is named. Start by locating the std::pair and std::tuple implementations and reviewing the repository’s vNext ABI-break discussion, then determine whether trivial copy construction and assignment can be added without violating the ABI plan. Done means a decided scope and corresponding implementation and regression tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.