[SERVER-45591] Improve is_copy_constructible calls in future impl Created: 15/Jan/20  Updated: 29/Oct/23  Resolved: 04/May/20

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 4.7.0

Type: Improvement Priority: Major - P3
Reporter: Mira Carey Assignee: Spencer Brody (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
Backwards Compatibility: Fully Compatible
Sprint: Service Arch 2020-03-23, Service Arch 2020-04-06, Service arch 2020-05-04, Service arch 2020-05-18
Participants:
Linked BF Score: 0

 Description   

Our future's code makes use of a std::is_copy_constructible_v call inside fillChildren to avoid attempting to instantiate implementations for move only T's. There are also a few other static_asserts that check the same parameter.

The problem is that for every T, std::is_copy_constructible_v<std::vector<T>> == true, because std::vector is a crappy old type and always has a copy constructor (it just can't be instantiated for move only types). This causes our static_asserts to be worthless, and for Future<vector<MoveOnly>> to be uninstantiatable.

We should add some kind of util::is_actually_copy_constructible_v that has a special case for vector, and for anything else we end up finding, and use that instead. If we don't do that, the workaround is to wrap your vector's in types that you explicitly make move only, which isn't the best ergonomics



 Comments   
Comment by Githook User [ 04/May/20 ]

Author:

{'name': 'Spencer T Brody', 'email': 'spencer@mongodb.com', 'username': 'stbrody'}

Message: SERVER-45591 Fix unit test compile on Windows: MSVC does not allow vector<map<move-only type>>
Branch: master
https://github.com/mongodb/mongo/commit/aacb7410c83ed079fc62af94fa546dedc66b89fa

Comment by Githook User [ 30/Apr/20 ]

Author:

{'name': 'Spencer T Brody', 'email': 'spencer@mongodb.com', 'username': 'stbrody'}

Message: SERVER-45591 Fix is_really_copy_constructible and add more tests.
Branch: master
https://github.com/mongodb/mongo/commit/a6dbdff35b3367f110fca078980cc46c3752446e

Comment by Billy Donahue [ 23/Apr/20 ]

Reopening just to get my CR comments looked at. Sorry I was too late with them. We'll probably need another CR to roll it back or at least fix some problems with it (like opening the anonymous namespace in the header).

Comment by Githook User [ 23/Apr/20 ]

Author:

{'name': 'Spencer T Brody', 'email': 'spencer@mongodb.com', 'username': 'stbrody'}

Message: SERVER-45591 Allow Future<vector<move-only-type>> by adding is_really_copy_constructible type trait.
Branch: master
https://github.com/mongodb/mongo/commit/122dbabbb510f7e6bd822cc591c8224ae83e838d

Generated at Thu Feb 08 05:09:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.