-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vt: limit VtGetKnownValueTypeIndex to known types
Split known value type index generation into public & detail functions, where the public function, VtGetKnownValueTypeIndex, now issues a compile-time error when querying a type not known to Vt. This makes it safer to use with switch statements because returning -1 for unknown types would generate a case label that appears to match a specific type but actually matches any unknown type. switch (val.GetKnownValueTypeIndex()) { case VtGetKnownValueTypeIndex<double>(): // OK: double is known to Vt. val.Cast<float>(); break; case VtGetKnownValueTypeIndex<MyType>(): // Error: MyType is not known. val.Cast<MyOtherType>(); // `val` may be empty or break; // hold some other type. } VtIsKnownValueType() allows metaprograms to determine whether a type is in VT_VALUE_TYPES or not. Interally, VtValue uses Vt_KnownValueTypeDetail::GetIndex() to capture the held type's index, which returns -1 for types that are not known. (Internal change: 2258463)
- Loading branch information
Showing
3 changed files
with
79 additions
and
6 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
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