iterative-solver 0.0
 
Loading...
Searching...
No Matches
ArrayHandlerWithCopyFunc.h
1#ifndef LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_ARRAYHANDLERWITHCOPYFUNC_H
2#define LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_ARRAYHANDLERWITHCOPYFUNC_H
3#include <functional>
4#include <molpro/linalg/array/ArrayHandler.h>
5#include <utility>
6
7namespace molpro::linalg::array {
8
15template <class AL, class AR = AL>
16class ArrayHandlerWithCopyFunc : public ArrayHandler<AL, AR> {
17public:
18 using copy_func_type = std::function<AL(const AR &)>;
19
25 : ArrayHandler<AL, AR>(), m_copy_func(std::move(copy_func)) {}
26
27 AL copy(const AR &source) override {
28 this->m_counter->copy++;
29 return m_copy_func(source);
30 };
31 using ArrayHandler<AL, AR>::copy;
32
33protected:
35};
36
37} // namespace molpro::linalg::array
38#endif // LINEARALGEBRA_SRC_MOLPRO_LINALG_ARRAY_ARRAYHANDLERWITHCOPYFUNC_H
Base for handlers whose left arrays are created by a function given by the user.
Definition ArrayHandlerWithCopyFunc.h:16
AL copy(const AR &source) override
Definition ArrayHandlerWithCopyFunc.h:27
ArrayHandlerWithCopyFunc(copy_func_type copy_func)
Constructor taking a copy function.
Definition ArrayHandlerWithCopyFunc.h:24
std::function< AL(const AR &)> copy_func_type
Definition ArrayHandlerWithCopyFunc.h:18
copy_func_type m_copy_func
function for making a copy
Definition ArrayHandlerWithCopyFunc.h:34
Enhances various operations between pairs of arrays and allows dynamic code injection with uniform in...
Definition ArrayHandler.h:163
std::unique_ptr< Counter > m_counter
Definition ArrayHandler.h:177
Definition ArrayHandler.h:19