I m wondering how to make same type for return value? Consider an example:
auto get_securities_by_mic(const std::string& mic)
{
auto it = some_map.find(mic);
// I want to write like this:
if (it == some_map.end()) return std::views::empty<const Security&>;
return it->second | std::views::transform([](id)->const Security&{...});
}
But it code cannot be compiled(
I came up with solution:
auto get_securities_by_mic(const std::string& mic)
{
auto it = some_map.find(mic);
static const std::vector<std::int64_t> empty;
auto source = it != some_map.end() ? std::views::all(it->second) : std::views::all(empty);
return source | std::views::transform([](id) -> const Security&{...});
}
Can I write somehow better?