Advertisement
bayerb

result.hpp

Mar 20th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #ifndef RESULT_H
  2. #define RESULT_H
  3.  
  4. #include <array>
  5.  
  6. namespace result {
  7.  
  8. template <typename valuetype, int size> class Result {
  9.  
  10. public:
  11.   Result(std::array<valuetype, size> _Values, int _Id)
  12.       : Id(_Id), Values(_Values){};
  13.  
  14.   Result(const Result &other) : Id(other.Id), Values(other.Values){};
  15.  
  16.   Result(Result &&other) noexcept {
  17.     Id = other.Id;
  18.     Values = std::move(other.Values);
  19.   }
  20.  
  21.   ~Result(){};
  22.  
  23.   Result &operator=(const Result &other) {
  24.     Result tmp(other);
  25.     *this = std::move(tmp);
  26.     return *this;
  27.   }
  28.  
  29.   Result &operator=(const Result &&other) noexcept {
  30.     Id = other.Id;
  31.     Values = std::move(other.Values);
  32.     return *this;
  33.   }
  34.  
  35.   const std::array<valuetype, size> &getValues() const { return Values; };
  36.   std::array<valuetype, size> &setValues() { return Values; };
  37.   const int &getId() const { return Id; };
  38.   int &setId() { return Id; };
  39.  
  40. private:
  41.   int Id;
  42.   std::array<valuetype, size> Values;
  43. };
  44. }
  45.  
  46. #endif // RESULT_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement