Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //<--- delta - function --->
- enum class delta_function_type { encode, decode };
- template<delta_function_type T>
- class delta_function {
- public:
- int operator()(int in);
- private:
- int last = 0;
- };
- template <>
- int inline delta_function<delta_function_type::encode>::operator()(int in) {
- int current = in;
- int res = current - last;
- last = current;
- return res;
- }
- template <>
- int inline delta_function<delta_function_type::decode>::operator()(int in) {
- int res = in + last;
- last = res;
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement