/*!
* \file integralconstant.h
* \brief Template meta-programming integral constant
*
* Copyright (C) 2018-2019 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_integralconstant_h__
#define __utl_meta_integralconstant_h__
#include
#include
#include
/*!
* \ingroup meta
* \defgroup integral
* integral constant support header
*/
//! @{
namespace utl {
namespace meta {
/*!
* Empty type
* utl::meta's nil type is not pure nil. It's a recursive "de-referencable nil.
* Each time someone applies ::type to it, he gets back nil_. This way we can prevent
* a lot of compilation errors in a wrong meta:: handling.
*/
struct nil_ {
using type = nil_;
};
//! Type alias for \p Tp::type. Used to evaluate/extract return type of metafunctions
template
using eval = typename Tp::type;
//! integral_
//! Integral Constant is a holder class for a compile-time value of an integral type.
//! Every Integral Constant is also a null-ary Metafunction, returning itself.
//! An integral constant object is implicitly convertible to the corresponding
//! run-time value of the wrapped integral type
//! @{
template
using integral_ = std::integral_constant;
//! @}
//! Wrappers for basic types
//! @{
//! bool_ type: integral constant wrapper for bool
template
using bool_ = integral_;
using true_ = bool_; //!< The type used as a compile-time boolean with true value.
using false_ = bool_; //!< The type used as a compile-time boolean with false value.
//! int8_ type: integral constant wrapper for \c int8_t
template
using int8_ = integral_;
//! uint8_ type: integral constant wrapper for \c uint8_t
template
using uint8_ = integral_;
//! int16_ type: integral constant wrapper for \c int16_t
template
using int16_ = integral_;
//! uint16_ type: integral constant wrapper for \c uint16_t
template
using uint16_ = integral_;
//! int32_ type: integral constant wrapper for \c int32_t
template
using int32_ = integral_;
//! uint32_ type: integral constant wrapper for \c uint32_t
template
using uint32_ = integral_;
//! char_ type: integral constant wrapper for \c char
template
using char_ = integral_;
//! int_ type: integral constant wrapper for \c int
template
using int_ = integral_;
//! long_ type: integral constant wrapper for \c long
template
using long_ = integral_;
//! index_ type: integral constant wrapper for \c index_t a.k.a std::size_t
template
using index_ = integral_;
//! size_ type: integral constant wrapper for \c size_t a.k.a std::size_t
template
using size_ = integral_;
//! Computes the size of the type \p Tp.
//! Complexity \f$ O(1) \f$.
template
using sizeof_ = size_;
//! Computes the alignment required for any instance of the type \p Tp.
//! Complexity \f$ O(1) \f$.
template
using alignof_ = size_;
//! @}
//! The last position we can express for indexing
using Npos = size_;
//! integer sequence
//! @{
template< class Tp, Tp... Ints >
using integer_sequence = std::integer_sequence;
template
using make_integer_sequence = std::make_integer_sequence;
//! Alias template index_sequence
template
using index_sequence = integer_sequence;
//! Alias template make_index_sequence
template
using make_index_sequence = make_integer_sequence ;
//! Alias template index_sequence_for
template
using index_sequence_for = make_index_sequence;
//! @}
}}
//!@}
#endif /* __utl_meta_integralconstant_h__ */