meta: Small changes and detect idiom
This commit is contained in:
parent
9afa3e4f7b
commit
36f0494e8f
@ -20,7 +20,7 @@
|
|||||||
#ifndef __utl_meta_bool_h__
|
#ifndef __utl_meta_bool_h__
|
||||||
#define __utl_meta_bool_h__
|
#define __utl_meta_bool_h__
|
||||||
|
|
||||||
#include <utl/impl/version.h>
|
#include <utl/impl/impl.h>
|
||||||
#include <utl/meta/integral.h>
|
#include <utl/meta/integral.h>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
70
include/utl/meta/detect.h
Normal file
70
include/utl/meta/detect.h
Normal 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__ */
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef __utl_meta_if_h__
|
#ifndef __utl_meta_if_h__
|
||||||
#define __utl_meta_if_h__
|
#define __utl_meta_if_h__
|
||||||
|
|
||||||
#include <utl/impl/version.h>
|
#include <utl/impl/impl.h>
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef __utl_meta_integral_h__
|
#ifndef __utl_meta_integral_h__
|
||||||
#define __utl_meta_integral_h__
|
#define __utl_meta_integral_h__
|
||||||
|
|
||||||
#include <utl/impl/version.h>
|
#include <utl/impl/impl.h>
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \ingroup meta
|
* \ingroup meta
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef __utl_meta_logical_h__
|
#ifndef __utl_meta_logical_h__
|
||||||
#define __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/bool.h>
|
||||||
#include <utl/meta/if.h>
|
#include <utl/meta/if.h>
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef __utl_meta_use_h__
|
#ifndef __utl_meta_use_h__
|
||||||
#define __utl_meta_use_h__
|
#define __utl_meta_use_h__
|
||||||
|
|
||||||
#include <utl/impl/version.h>
|
#include <utl/impl/impl.h>
|
||||||
#include <utl/meta/logical.h>
|
#include <utl/meta/logical.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef __utl_meta_void_h__
|
#ifndef __utl_meta_void_h__
|
||||||
#define __utl_meta_void_h__
|
#define __utl_meta_void_h__
|
||||||
|
|
||||||
#include <utl/impl/version.h>
|
#include <utl/impl/impl.h>
|
||||||
#include <utl/meta/bool.h>
|
#include <utl/meta/bool.h>
|
||||||
|
|
||||||
/*! \ingroup meta
|
/*! \ingroup meta
|
||||||
|
Loading…
x
Reference in New Issue
Block a user