span.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
  2. // Copyright 2008-2016 National ICT Australia (NICTA)
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // ------------------------------------------------------------------------
  15. //! \addtogroup span
  16. //! @{
  17. struct span_alt {};
  18. template<typename junk = int>
  19. class span_base
  20. {
  21. public:
  22. static const span_alt all;
  23. };
  24. template<typename junk>
  25. const span_alt span_base<junk>::all = span_alt();
  26. class span : public span_base<>
  27. {
  28. public:
  29. uword a;
  30. uword b;
  31. bool whole;
  32. inline
  33. span()
  34. : a(0)
  35. , b(0)
  36. , whole(true)
  37. {
  38. }
  39. inline
  40. span(const span_alt&)
  41. : a(0)
  42. , b(0)
  43. , whole(true)
  44. {
  45. }
  46. inline
  47. explicit
  48. span(const uword in_a)
  49. : a(in_a)
  50. , b(in_a)
  51. , whole(false)
  52. {
  53. }
  54. // the "explicit" keyword is required here to prevent a C++11 compiler
  55. // automatically converting {a,b} into an instance of span() when submatrices are specified
  56. inline
  57. explicit
  58. span(const uword in_a, const uword in_b)
  59. : a(in_a)
  60. , b(in_b)
  61. , whole(false)
  62. {
  63. }
  64. };
  65. //! @}