Micro template library A library for building device drivers
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

55 lignes
1.5 KiB

  1. /*!
  2. * \file integral.h
  3. * \brief Template meta-programming integral constant
  4. *
  5. * Copyright (C) 2018 Christos Choutouridis
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as
  9. * published by the Free Software Foundation, either version 3
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef __utl_meta_integral_h__
  21. #define __utl_meta_integral_h__
  22. #include <utl/impl/impl.h>
  23. /*!
  24. * \ingroup meta
  25. * \defgroup integral
  26. * integral constand support header
  27. */
  28. //! @{
  29. namespace utl {
  30. //! integral_constant
  31. template <typename _Tp, _Tp _v>
  32. struct integral_ {
  33. using value_type = _Tp;
  34. using type = integral_<_Tp, _v>;
  35. constexpr operator value_type() const {
  36. return value;
  37. }
  38. constexpr value_type operator()() const {
  39. return value;
  40. }
  41. static constexpr _Tp value = _v;
  42. };
  43. template<typename _Tp, _Tp _v>
  44. constexpr _Tp integral_<_Tp, _v>::value;
  45. }
  46. //!@}
  47. #endif /* __utl_meta_integral_h__ */