Micro template library A library for building device drivers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

53 lines
1.7 KiB

  1. /*!
  2. * \file void_t.h
  3. * \brief Template meta-programming helpers
  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_void_t_h__
  21. #define __utl_meta_void_t_h__
  22. #include <utl/impl/version.h>
  23. //! \ingroup meta
  24. //! \defgroup void_t
  25. //! A void_t implementation for utl
  26. //! @{
  27. namespace utl {
  28. /*!
  29. * Utility meta-function that maps a sequence of any types to the type void
  30. * \note The idea is:
  31. * template <typename ...>
  32. * using void_t = void;
  33. *
  34. * Until CWG 1558 (a C++14 defect), unused parameters in alias templates were not
  35. * guaranteed to ensure SFINAE and could be ignored, so earlier compilers require
  36. * a more complex definition of void_t, such as the following implementation
  37. * https://en.cppreference.com
  38. */
  39. template<typename... _Ts>
  40. struct void_impl {
  41. typedef void type;
  42. };
  43. //! The actual void_t type alias
  44. template<typename... _Ts>
  45. using void_t = typename void_impl<_Ts...>::type;
  46. }
  47. //! @}
  48. #endif /* __utl_meta_void_t_h__ */