Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fast forwarding as function arguments #62

Open
uselessgoddess opened this issue Jul 17, 2021 · 0 comments
Open

Fast forwarding as function arguments #62

uselessgoddess opened this issue Jul 17, 2021 · 0 comments
Labels
enhancement New feature or request performance This can be done faster

Comments

@uselessgoddess
Copy link
Member

uselessgoddess commented Jul 17, 2021

  • use const & for [big type] argument
  • use universal reference to forward template argument
  • use std::forward to forward template argument
auto function(std::vector<big_type>& list, big_type case1, const big_type& case2, auto&& case3)
{
    list.push_back(std::move(case1)) // one copy/only move, but call function(list, std::move(val), ..., ...)
    list.push_back(case2) // always one copy
    list.push_back(std::forward<decltype(case3)>(case3)) // same case1 but have other features
}
auto function(big_type case1, const big_type& case2, auto&& case3)
{
    case1.readonly_func() // (( always one copy 
    case2.readonly_func() // )) no copy
    case3.readonly_func() // )) no copy
}
@uselessgoddess uselessgoddess added enhancement New feature or request performance This can be done faster labels Jul 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance This can be done faster
Projects
None yet
Development

No branches or pull requests

1 participant