-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow hashtable to work with incomplete types.
Experimentally verified using Ubuntu g++-5.4 and Apple clang-800.0.42.1. The main issue is that some of our type_traits checks get instantiated in compilation before the type is fully defined, which leads to a compilation error. So we play some tricks to try and get them instantiated later. 1) declare operator<< and operator>> as friends to a generic KeyType and TType, and use std::is_trivial on the function-specific templates. That way, the types are instantiated after the class is defined. 2) Turn the is_simple and is_data_nothrow_move_constructible cosntexpr booleans into constexpr methods. This seems to let them get instantiated later. This also lets us use an incomplete key type, if so desired. I'm not really sure if these fixes are future-proof, because they seem to rely on compiler implementation details, and not some standards-documented behavior, though I haven't really looked through the standard to verify.
- Loading branch information
Showing
2 changed files
with
23 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters