Micro template library A library for building device drivers
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

71 行
2.1 KiB

  1. /*!
  2. * \file sfinae.h
  3. * \brief Template meta-programming SFINAE helpers
  4. *
  5. * \copyright
  6. * Copyright (C) 2018 Christos Choutouridis <christos@choutouridis.net>\n
  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.\n
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Lesser General Public License for more details.\n
  15. * You should have received a copy of the GNU Lesser General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __utl_meta_sfinae_h__
  19. #define __utl_meta_sfinae_h__
  20. #include <utl/core/impl.h>
  21. #include <type_traits>
  22. /*!
  23. * \ingroup meta
  24. * \defgroup sfinae sfinae
  25. * conditional use support header.
  26. */
  27. //! @{
  28. namespace utl {
  29. namespace meta {
  30. //! \name when implementation
  31. //! @{
  32. namespace details {
  33. // template <typename... T>
  34. // struct dev_null { using type = dev_null; }; //< Same as typelist
  35. template <bool If> struct when_ { };
  36. template <> struct when_<true> { using type = void; };
  37. }
  38. //! Tool to enable a partial specialization only if a boolean condition is true.
  39. //! Well formed only if \p If is true
  40. template <bool If>
  41. using when = eval_t< details::when_<If> >;
  42. // //! Well formed only if all of \p Ifs are \c true
  43. // template <bool ...Ifs>
  44. // using when_all = details::dev_null<
  45. // when<Ifs>...
  46. // >;
  47. //! @}
  48. //! \name enable_if from STL
  49. //! @{
  50. //! enable_if, imported from stl
  51. template <bool If, typename _Tp = void> using enable_if = std::enable_if<If, _Tp>;
  52. //! alias template for enable_if
  53. template<bool If, typename _Tp = void> using enable_if_t = eval_t< enable_if<If, _Tp> >;
  54. //! @}
  55. }}
  56. //! @}
  57. #endif /* __utl_meta_sfinae_h__ */