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

Modernize code base to C++11 (first) #79

Open
fangism opened this issue Dec 31, 2024 · 2 comments
Open

Modernize code base to C++11 (first) #79

fangism opened this issue Dec 31, 2024 · 2 comments
Assignees

Comments

@fangism
Copy link
Owner

fangism commented Dec 31, 2024

In its current state, the code base compiles using the C++98 standard. It is year 2025 soon. It struggles to compile with most reasonably recent compilers. Modernization will need to be done in phases, rather than jumping to c++20 or c++23 all at once.

Phase 1: compile against -std=c++11 before we jump to c++14, c++17, etc. c++11 was a "great leap forward", and this transition is expected to be laborious. Changes to this effect will happen on the remove-STL-fwd branch.

Some suggested configuration options for testing:
configure CC="clang-16" CXX="clang++-16" CXXFLAGS='CXXFLAGS=-g -O2 -std=c++11 -Wno-unused-local-typedef'

@fangism fangism self-assigned this Dec 31, 2024
@fangism
Copy link
Owner Author

fangism commented Dec 31, 2024

Notes: std::binary_function and std::unary_function were marked deprecated in C++11, with the introduction of lambdas. Conditioning the code to work both pre- and post-c++11 is quite possibly more effort than it is worth. We are going to rely heavily on the unit-tests and integration-tests to prevent breakage in this transition.

@fangism
Copy link
Owner Author

fangism commented Dec 31, 2024

Related <functional>-code in hackt's code base:

  • util/compose.hh for unary_compose and binary_compose. Replace these with lambdas.
  • util/deference.hh for dereference. Can be replaced with lambdas.
  • many uses of std::mem_fun_ref, to be replaced by std::mem_fn. Replaceable with lambdas.
  • std::bind2nd and std::bind1st to be replaced by std::bind, or just lambdas with captures.

Pointer management:

  • replace excl_ptr withstd::unique_ptr and replace count_ptr with std::shared_ptr. These are not perfect drop-in replacements, some additional work is expected around object serialization persistent_object_manager.

(just to name a few)

fangism added a commit that referenced this issue Feb 7, 2025
Replacing old-style functors with ranged-for loops or lambdas.
All changes are still conditioned on __cplusplus >= 201103L.

For #79
fangism added a commit that referenced this issue Feb 7, 2025
More re-writes in C++11 style without old
C++98 functional utilities.

For #79
fangism added a commit that referenced this issue Feb 14, 2025
Rewriting some functional constructs and loops to
use ranges or lambdas.

For #79
fangism added a commit that referenced this issue Mar 13, 2025
fangism added a commit that referenced this issue Mar 13, 2025
For now remove deprecated headers from distribution.
To test with pre-C++11, add these back to the non-deprecated list.
Future clean up will remove these permanently.

For #79
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant