FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[QUESTION] how to express this code in CppFront (is it possible)? · Issue #1235 · hsutter/cppfront · GitHub

[QUESTION] how to express this code in CppFront (is it possible)? #1235

Description

Hello community,

I am trying to translate this piece of C++ code into Cppfront:

template<class AssocContainer, class Func = std::plus<>>
void
combine_maps(AssocContainer& map1, const AssocContainer& map2, Func func = {})
{
    for (const auto& [k, v] : map2)
        map1[k] = func(map1[k], v);
}

And I tried this:

combine_maps:<AssocContainer, Func: type = std::plus<>>(inout map1: AssocContainer, map2: AssocContainer, func: Func = ()) = {
    for map2 do(kv) {
        map1[kv.first] = func(map1[kv.first], kv.second);
    }
}

My questions are simple:

  1. is there a way to default the template parameter to std::plus<> as in plain C++?
  2. is there a way to bind key and value in Cpp2 in a similar way to a structured binding? Maybe with pattern matching of some kind?
  3. can I default func: Func = () parameter? It seems to emit code where there is const Func & func = <empty here>

Thank you for your time and support to everyone.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL