-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Dipl.-Phys. Frank Haferkorn edited this page May 28, 2020
·
3 revisions
This GITHUB-REPO is a testbed for a special kind of Modern C++ CORE LANGUAGE-extension.
- loop(N, ...){}
- typed_loop(type, N, ...)
- named_loop_up(id, N, ...){}
- named_loop_down(id, N, ..){}
With optional opt-opration expressions. N should be of integral type. These new COMPOUNDs can be easily imlemented via the cpp-preprocessor.
more examples: https://github.com/F-Haferkorn/ogis-modern-cxx-future-cpp/tree/master/future-cpp-loop/ogis-cpp-loop.examples/examples
template<typename TPtr, typename TRowSize, typename TColSize, typename TStrideSize > TPtr matrix_copy( TPtr tgt, TPtr src, TRowSize nRows, TColSize nColumns, TStrideSize stride) { // compiler can mangled the loop-internal integral-types tgt and src in registers. loop(nRows, tgt+=stride, src+=stride) // apply strid eafter each row to tgt and src loop(nbofColumms, tgt++, src++) *tgt = *src; return tgt; }
Advantages With recent compilers this gives no really speed advantage, but is no way slower than a full for(;;){} iteration.
And it increases readability.
Future C/C++ compilers can take advantage the reduced degree of freedom of the iteration and make e.g. heavily use of ALU-register operation of DSP-Architectures