BLI: improve CPPType system
* Support bidirectional type lookups. E.g. finding the base type of a field was supported, but not the other way around. This also removes the todo in `get_vector_type`. To achieve this, types have to be registered up-front. * Separate `CPPType` from other "type traits". For example, previously `ValueOrFieldCPPType` adds additional behavior on top of `CPPType`. Previously, it was a subclass, now it just contains a reference to the `CPPType` it corresponds to. This follows the composition-over-inheritance idea. This makes it easier to have self-contained "type traits" without having to put everything into `CPPType`. Differential Revision: https://developer.blender.org/D16479
This commit is contained in:
@@ -23,6 +23,13 @@ template<typename T, T Element> struct TypeForValue {
|
||||
static constexpr T value = Element;
|
||||
};
|
||||
|
||||
/**
|
||||
* A struct that allows passing in a type as a function parameter.
|
||||
*/
|
||||
template<typename T> struct TypeTag {
|
||||
using type = T;
|
||||
};
|
||||
|
||||
/**
|
||||
* A type that encodes a list of values of the same type.
|
||||
* This is similar to #std::integer_sequence, but a bit more general. It's main purpose it to also
|
||||
|
||||
Reference in New Issue
Block a user