PolyBoRi
CCheckedIdx.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
14 //*****************************************************************************
15 
16 #ifndef polybori_common_CCheckedIdx_h_
17 #define polybori_common_CCheckedIdx_h_
18 
19 // include basic definitions
20 #include <polybori/pbori_defs.h>
21 
23 
30  public CTypes::auxtypes_type {
31 
33  typedef CCheckedIdx self;
34 
35 public:
36  CCheckedIdx(idx_type idx): m_idx(idx) {
37  if PBORI_UNLIKELY(idx < 0) handle_error();
38  }
39  CCheckedIdx(const self& rhs): m_idx(rhs.m_idx) { }
41 
42  operator idx_type() const { return m_idx; }
43 private:
44  void handle_error() const;
45  idx_type m_idx;
46 };
47 
49 
50 #endif