Browse Source

meta: Small changes and detect idiom

doc
Christos Houtouridis 5 years ago
parent
commit
36f0494e8f
7 changed files with 76 additions and 6 deletions
  1. +1
    -1
      include/utl/meta/bool.h
  2. +70
    -0
      include/utl/meta/detect.h
  3. +1
    -1
      include/utl/meta/if.h
  4. +1
    -1
      include/utl/meta/integral.h
  5. +1
    -1
      include/utl/meta/logical.h
  6. +1
    -1
      include/utl/meta/sfinae.h
  7. +1
    -1
      include/utl/meta/void.h

+ 1
- 1
include/utl/meta/bool.h View File

@@ -20,7 +20,7 @@
#ifndef __utl_meta_bool_h__
#define __utl_meta_bool_h__
#include <utl/impl/version.h>
#include <utl/impl/impl.h>
#include <utl/meta/integral.h>
/*!


+ 70
- 0
include/utl/meta/detect.h View File

@@ -0,0 +1,70 @@
/*!
* \file utl/meta/detect.h
* \brief Template meta-programming void helpers
*
* Copyright (C) 2018 Christos Choutouridis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __utl_meta_detect_h__
#define __utl_meta_detect_h__
#include <utl/impl/impl.h>
#include <utl/meta/sfinae.h>
/*!
* \ingroup meta
* \defgroup detect
* Implementation of the detection idiom
*/
//! @{
namespace utl {
//! detection idiom (negative case).
template <typename _Def,
typename _AlwaysVoid,
template<typename...> class _Op,
typename... _Args>
struct detector_ {
using value_ = false_;
using type = _Def;
};
//! detection idiom (positive case).
template <typename _Def,
template<typename...> class _Op,
typename... _Args>
struct detector_ <_Def, void_t<_Op<_Args...>>, _Op, _Args...> {
using value_ = true_;
using type = _Op<_Args...>;
};
// Detect whether _Op<_Args...> is a valid type, use _Def if not.
template <typename _Def,
template<typename...> class _Op,
typename... _Args>
using detected_or_ = detector_ <_Def, void, _Op, _Args...>;
// template alias
template <typename _Def,
template<typename...> class _Op,
typename... _Args>
using detected_or_t = typename detected_or_<_Def, _Op, _Args...>::type;
}
//! @}
#endif /* __utl_meta_detect_h__ */

+ 1
- 1
include/utl/meta/if.h View File

@@ -20,7 +20,7 @@
#ifndef __utl_meta_if_h__
#define __utl_meta_if_h__
#include <utl/impl/version.h>
#include <utl/impl/impl.h>
/*!


+ 1
- 1
include/utl/meta/integral.h View File

@@ -20,7 +20,7 @@
#ifndef __utl_meta_integral_h__
#define __utl_meta_integral_h__
#include <utl/impl/version.h>
#include <utl/impl/impl.h>
/*!
* \ingroup meta


+ 1
- 1
include/utl/meta/logical.h View File

@@ -20,7 +20,7 @@
#ifndef __utl_meta_logical_h__
#define __utl_meta_logical_h__
#include <utl/impl/version.h>
#include <utl/impl/impl.h>
#include <utl/meta/bool.h>
#include <utl/meta/if.h>


+ 1
- 1
include/utl/meta/sfinae.h View File

@@ -20,7 +20,7 @@
#ifndef __utl_meta_use_h__
#define __utl_meta_use_h__
#include <utl/impl/version.h>
#include <utl/impl/impl.h>
#include <utl/meta/logical.h>


+ 1
- 1
include/utl/meta/void.h View File

@@ -20,7 +20,7 @@
#ifndef __utl_meta_void_h__
#define __utl_meta_void_h__
#include <utl/impl/version.h>
#include <utl/impl/impl.h>
#include <utl/meta/bool.h>
/*! \ingroup meta


Loading…
Cancel
Save