SHARE
TWEET

Untitled

denis_adamchuk Nov 12th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <functional>
  2. #include <vector>
  3. #include <utility>
  4.  
  5.    struct DomTestParameters
  6.    {
  7.       std::pair<double, double> output;
  8.       int period;
  9.       double tickSize = 0.0;
  10.    };
  11.  
  12. bool executeTestA(std::vector<DomTestParameters>& params,
  13.    const std::function<std::pair<double, double>(const DomTestParameters&, int, double)>& func)
  14. {
  15.    for (auto& item : params)
  16.    {
  17.       const auto calculated = func({}, item.period, item.tickSize);
  18.       return calculated.first > calculated.second;
  19.    }
  20.    return true;
  21. }
  22.  
  23. template <typename TFn>
  24. bool executeTestB(std::vector<DomTestParameters>& params, const TFn& func)
  25. {
  26.    for (auto& item : params)
  27.    {
  28.       const auto calculated = func({}, item.period, item.tickSize);
  29.       return calculated.first > calculated.second;
  30.    }
  31.    return true;
  32. }
  33.  
  34. std::pair<double, double> GetAsk(const DomTestParameters& x, int y, double z)
  35. {
  36.     return {};
  37. }
  38.  
  39. std::pair<double, double> GetAsk2(const DomTestParameters& x, int y)
  40. {
  41.     return {};
  42. }
  43.  
  44. int main(int argc, char* argv[])
  45. {
  46.     std::vector<DomTestParameters> xx;
  47.     return executeTestA(xx, [](const DomTestParameters& x, int y, double z){ return GetAsk(x, y, z); }) ||
  48.            executeTestA(xx, [](const DomTestParameters& x, int y, double){ return GetAsk2(x, y); })     ||
  49.            executeTestB(xx, [](const DomTestParameters& x, int y, double z){ return GetAsk(x, y, z); }) ||
  50.            executeTestB(xx, [](const DomTestParameters& x, int y, double){ return GetAsk2(x, y); });
  51. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top