Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

How to efficiently bind either an lvalue or rvalue to the same reference?

I'd create separate function, which accept reference and call it, like this:

void func( MyObject const & original ) {
    if (apply_alteration)
        func_internal(alter_obj(original));
    else
        func_internal(original);
}

void func_internal( MyObject const & possibly_altered) {
    // ...
}

Tags:

C++

Reference

Ternary Operator

Lvalue

Rvalue

Related

VSCode Emmet html boilerplate? Summing values in R based on column value with dplyr Mapstruct: HashMap as source to Object Firestore: How to query data from a map of an array How to set FLASK_ENV inside config file? How to fix "Violation of Usage of Android Advertising ID policy and section 4.8 of the Developer Distribution Agreement" .NET Core 3.0: Razor views don't automatically recompile on change Where does active storage store files (on disk), and how can I retrieve them physically? What determines if rails includes id: :serial in a table definition? Gradle 5 JUnit BOM and Spring Boot Incorrect Versions Python: 'ModuleNotFoundError' when trying to import module from imported package Why will "while true" use 100% of CPU resources?

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy