-
Notifications
You must be signed in to change notification settings - Fork 449
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Getting the nested type of an array (vector) type? #58
Comments
You are absolutely right. That is not possible at the moment. The big problem here is the distinction between types and non-type template parameters (like
|
Hmm, that seems complicated. I had a go at figuring out a solution, but I didn't manage it. Perhaps it's possible to start with just an implementation of this for arrays, etc? There's already some custom work done for them through things like If you can give me some pointers in the direction of where to start implementing this, I'd be happy to do it. |
I have a direction for you now. Maybe you are a preprocessor magician? 😏 But can you live with something like this? When we doing a general solution, you would get something like this:
|
I'm not sure I understand your solution. I had a look at the code, but my template-fu is not strong enough :) What kind of macro magic do you need? |
I can elaborate this later in detail. More important is this:
For an std::string you will get 3 types:
Is this too "good" for you? |
Ah sorry, I missed your question. Yes, that's fine for me. The thing I'm using this for is to be able to calculate a version number for an RTTR type for binary serialization and such, so including all nested types in the version is fine. |
Consider the following example:
Assuming that DataStruct and SomeClass and their properties are registered in the type system, is there a way to determine/get the nested
type
ofstd::vector<DataStruct>
property using RTTR? For example, in this example, the nested type of thestd::vector<DataStruct>
isDataStruct
.I've found the
get_rank_type
functions invariant_array_view
that can do this, but those require an instance of the vector to be able to create thevariant_array_view
. While I could create an instance of the vector, it seems needlessly expensive to do that just to determine the type of the array. In addition, creating an instance through RTTR also requires the specific vector specialization to be registered with RTTR in order for a constructor to be present, so it's quite inconvenient.Is there a better way to determine the type?
(Background information: I'm trying to use this to (recursively) collect a list of all types used by a specific type, so I don't actually have an instance lying around)
EDIT: The above example is for arrays/vectors, but the same goes for associative containers, i.e. std::map and friends; I'd like to retrieve their key and value types as well.
The text was updated successfully, but these errors were encountered: