/*!
* \file selection.h
* \brief Template meta-programming type selections.
*
* 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 .
*/
#ifndef __utl_meta_selection_h__
#define __utl_meta_selection_h__
#include
#include
#include
/*!
* \ingroup meta
* \defgroup type selection
* Type selection support header
*/
//! @{
namespace utl {
namespace meta{
/*!
* Type selection
*/
//! @{
//! if_, if_c
//! @{
namespace detail {
template
struct if_c_ {
using type = nil_; //!< avoid ill formed result
};
template
struct if_c_ {
using type = Then;
};
template
struct if_c_ {
using type = Then;
};
template
struct if_c_ {
using type = Else;
};
}
//! Select one type or another depending on a compile-time Boolean.
template
using if_c = type_>;
//! Select one type or another depending on a compile-time Boolean type
template
using if_ = if_c;
//! @}
/*!
* Named type selectors
*/
//! @{
//! Select the first type of a type sequence
template
struct first_of {
using type = T1;
};
//! Select the second type of a type sequence
template
struct second_of {
using type = T2;
};
//! @}
}}
//! @}
#endif /* __utl_meta_selection_h__ */