iterating over a static std::vector

Jan 16, 2022 at 4:47am
So I have a static std::vector like this:
1
2
3
4
5
6
7
static std::vector<ApiWrapper> api_handlers = {
    Rtl::RtlDuplicateUnicodeString,
    Rtl::RtlInitUnicodeString,
    Rtl::RtlPrefixUnicodeString,
    Rtl::RtlTimeToTimeFields, 
    Rtl::RtlMultiByteToUnicodeN
};


I am iterating through the vector like this:
1
2
3
4
5
6
7

   auto entry = std::find_if(ApiWrappers::api_handlers.begin(), ApiWrappers::api_handlers.end(),
                [&](ApiWrapper& handler) -> bool {
// ApiWrapper& handler members are all NULL for some reason, even though ApiWrappers is filled with initialized elements
                    return (handler->address == target_addr);
                }
            );


Why do all iterators point to empty structs, even though the vector is filled with defined elements?
Last edited on Jan 16, 2022 at 4:49am
Jan 16, 2022 at 10:12pm
- Can you show a minimal compileable example?
- What library is this?
- The "->" operator usually doesn't apply to a non-pointer, so it must be overloaded in some way -- how?
Last edited on Jan 16, 2022 at 10:45pm
Jan 17, 2022 at 12:22pm
How do these structures look like? Particularly ApiWrapper?
Jan 17, 2022 at 1:04pm
@Ganado, the -> is for the trailing return type of the lambda, not for a pointer.
Jan 17, 2022 at 1:29pm
@George P
I would think that Ganado talks about that operator: handler->address
Jan 17, 2022 at 8:06pm
Do you check whether entry == ApiWrappers::api_handlers.end() after the call to find_if()?
Jan 18, 2022 at 8:59am
Is this NULL?
 
*ApiWrappers::api_handlers.begin()
Jan 18, 2022 at 2:28pm
crickets
Jan 18, 2022 at 5:23pm
Topic archived. No new replies allowed.