MCPcopy Create free account
hub / github.com/docopt/docopt.cpp / flat_filter

Function flat_filter

docopt.cpp:152–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150// Get all instances of 'T' from the pattern
151template <typename T>
152std::vector<T*> flat_filter(Pattern& pattern) {
153 std::vector<Pattern*> flattened = pattern.flat([](Pattern const* p) -> bool {
154 return dynamic_cast<T const*>(p) != nullptr;
155 });
156
157 // now, we're guaranteed to have T*'s, so just use static_cast
158 std::vector<T*> ret;
159 std::transform(flattened.begin(), flattened.end(), std::back_inserter(ret), [](Pattern* p) {
160 return static_cast<T*>(p);
161 });
162 return ret;
163}
164
165static std::vector<std::string> parse_section(std::string const& name, std::string const& source) {
166 // ECMAScript regex only has "?=" for a non-matching lookahead. In order to make sure we always have

Callers

nothing calls this directly

Calls 2

transformFunction · 0.85
flatMethod · 0.45

Tested by

no test coverage detected