Created
July 15, 2018 17:22
-
-
Save garyo/438c47e48a7d1efddce068dd717aa1b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <vector> | |
| struct add1_op { | |
| void operator()(const float x0, float& dst) const { | |
| dst = x0 + 1; | |
| } | |
| }; | |
| template<class Op> | |
| struct process_vec1 { | |
| void operator()(const std::vector<float> src, std::vector<float> dst) const { | |
| for (size_t i = 0; i < src.size(); i++) { | |
| Op{}(src[i], dst[i]); | |
| } | |
| } | |
| }; | |
| template<typename Processor> | |
| void dispatch(const std::vector<float> src, std::vector<float> dst, int mode) | |
| { | |
| if (mode == 0) | |
| Processor()(src, dst); | |
| // ... other modes ... | |
| } | |
| void add1_vec(const std::vector<float> src, std::vector<float> dst, int mode) | |
| { | |
| dispatch<process_vec1<add1_op> >(src, dst, mode); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment