[SERVER-51888] Add TS2's std::is_detected etc API to stdx Created: 30/Oct/20 Updated: 29/Oct/23 Resolved: 31/Oct/20 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Code |
| Affects Version/s: | None |
| Fix Version/s: | 4.9.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Billy Donahue | Assignee: | Billy Donahue |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||
| Sprint: | Service arch 2020-11-02 | ||||||||
| Participants: | |||||||||
| Description |
|
It's a pre-standard API. This is what stdx is for. https://en.cppreference.com/w/cpp/experimental/is_detected |
| Comments |
| Comment by Githook User [ 01/Nov/20 ] |
|
Author: {'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}Message: https://developercommunity.visualstudio.com/content/problem/936367/sfinae-sees-private-part-of-a-class.html |
| Comment by Billy Donahue [ 31/Oct/20 ] |
|
MSVC bug that expression sfinae doesn't consider access modifiers. So a private member function will incorrectly pass a detection idiom check. Then trying to call that function of course fails as usual. So you can't use is_detected on MSVC to correctly identify whether an object has a callable member function. It might have a private member function that would match the decltype call expression, and is_detected will indicate that it's callable anyway. I worked around it here by making a private function in ReplSetConfig public. It was an oversight anyway, but really I just got lucky. |
| Comment by Githook User [ 31/Oct/20 ] |
|
Author: {'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}Message: ReplSetConfigBase now needs a public serialize to work around MSVC bug |
| Comment by Billy Donahue [ 30/Oct/20 ] |
| Comment by Billy Donahue [ 30/Oct/20 ] |
|
taking this on as a prereq of skunkworks ASSERT_THAT project |