[SERVER-44049] Allow public constexpr StringData constructors Created: 16/Oct/19 Updated: 29/Oct/23 Resolved: 08/May/20 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 4.7.0 |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Benjamin Caimano (Inactive) | 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-05-18 | ||||||||
| Participants: | |||||||||
| Description |
|
StringData currently uses a private tag pattern for its constexpr ctor. Since modern compilers can throw from constexpr ctors, we should be able to make the public constructors safely constexpr now. |
| Comments |
| Comment by Githook User [ 08/May/20 ] | |||||
|
Author: {'name': 'Billy Donahue', 'email': 'billy.donahue@mongodb.com', 'username': 'BillyDonahue'}Message: | |||||
| Comment by Billy Donahue [ 05/May/20 ] | |||||
|
I have run into a need for this in the logv2 attribute static checking as well. | |||||
| Comment by Billy Donahue [ 30/Apr/20 ] | |||||
|
PoC w/Tests: http://mongodbcr.appspot.com/590660001 | |||||
| Comment by Billy Donahue [ 30/Apr/20 ] | |||||
|
This feature would have helped me implement " when the StringData literal operator""_sd moved to namespace mongo::literals, it was awkward to make it a friend of mongo::StringData. It would have required friendship across namespaces and a forward declaration. I chose to work around the lack of constexpr StringData ctors
This is not a good solution. The right way to do it is to have a public constexpr constructor. | |||||
| Comment by Mira Carey [ 29/Oct/19 ] | |||||
|
We don't immediately need this for anything. Feel free to reopen if something comes up in the future |