浏览代码

WIP: Documentation

doc
父节点
当前提交
6f30abde8f
共有 15 个文件被更改,包括 487 次插入498 次删除
  1. +47
    -64
      Doxyfile
  2. +14
    -16
      include/utl/core/crtp.h
  3. +17
    -15
      include/utl/core/impl.h
  4. +18
    -18
      include/utl/core/types.h
  5. +52
    -32
      include/utl/core/version.h
  6. +1
    -0
      include/utl/dev/dev_iterators.h
  7. +38
    -30
      include/utl/meta/basic.h
  8. +47
    -50
      include/utl/meta/detection.h
  9. +44
    -54
      include/utl/meta/invoke.h
  10. +19
    -17
      include/utl/meta/meta.h
  11. +101
    -103
      include/utl/meta/operations.h
  12. +19
    -26
      include/utl/meta/selection.h
  13. +20
    -21
      include/utl/meta/sfinae.h
  14. +27
    -27
      include/utl/meta/typelist.h
  15. +23
    -25
      include/utl/meta/useif.h

+ 47
- 64
Doxyfile 查看文件

@@ -1,4 +1,4 @@
# Doxyfile 1.8.14
# Doxyfile 1.8.13

# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
@@ -20,8 +20,8 @@
# This tag specifies the encoding used for all characters in the config file
# that follow. The default is UTF-8 which is also the encoding used for all text
# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv
# built into libc) for the transcoding. See
# https://www.gnu.org/software/libiconv/ for the list of possible encodings.
# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv
# for the list of possible encodings.
# The default value is: UTF-8.

DOXYFILE_ENCODING = UTF-8
@@ -58,7 +58,7 @@ PROJECT_LOGO =
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.

OUTPUT_DIRECTORY = W:\Work\Software\Libraries\utl\doc
OUTPUT_DIRECTORY = doc

# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
@@ -150,7 +150,7 @@ INLINE_INHERITED_MEMB = NO
# shortest path that makes the file name unique will be used
# The default value is: YES.

FULL_PATH_NAMES = YES
FULL_PATH_NAMES = NO

# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.
# Stripping is only done if one of the specified strings matches the left-hand
@@ -337,7 +337,7 @@ BUILTIN_STL_SUPPORT = YES
CPP_CLI_SUPPORT = NO

# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen
# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen
# will parse them like normal C++ but will assume all classes use public instead
# of private inheritance when no explicit protection keyword is present.
# The default value is: NO.
@@ -360,14 +360,14 @@ IDL_PROPERTY_SUPPORT = YES
# all members of a group must be documented explicitly.
# The default value is: NO.

DISTRIBUTE_GROUP_DOC = NO
DISTRIBUTE_GROUP_DOC = YES

# If one adds a struct or class to a group and this option is enabled, then also
# any nested class or struct is added to the same group. By default this option
# is disabled and one has to add nested compounds explicitly via \ingroup.
# The default value is: NO.

GROUP_NESTED_COMPOUNDS = NO
GROUP_NESTED_COMPOUNDS = YES

# Set the SUBGROUPING tag to YES to allow class member groups of the same type
# (for instance a group of public functions) to be put as a subgroup of that
@@ -397,7 +397,7 @@ INLINE_GROUPED_CLASSES = NO
# Man pages) or section (for LaTeX and RTF).
# The default value is: NO.

INLINE_SIMPLE_STRUCTS = NO
INLINE_SIMPLE_STRUCTS = YES

# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or
# enum is documented as struct, union, or enum with the name of the typedef. So
@@ -408,7 +408,7 @@ INLINE_SIMPLE_STRUCTS = NO
# types are typedef'ed and only the typedef is referenced, never the tag name.
# The default value is: NO.

TYPEDEF_HIDES_STRUCT = NO
TYPEDEF_HIDES_STRUCT = YES

# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This
# cache is used to resolve symbols given their name and scope. Since this can be
@@ -435,7 +435,7 @@ LOOKUP_CACHE_SIZE = 0
# normally produced when WARNINGS is set to YES.
# The default value is: NO.

EXTRACT_ALL = YES
EXTRACT_ALL = NO

# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
# be included in the documentation.
@@ -447,7 +447,7 @@ EXTRACT_PRIVATE = YES
# scope will be included in the documentation.
# The default value is: NO.

EXTRACT_PACKAGE = YES
EXTRACT_PACKAGE = NO

# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be
# included in the documentation.
@@ -469,7 +469,7 @@ EXTRACT_LOCAL_CLASSES = YES
# included.
# The default value is: NO.

EXTRACT_LOCAL_METHODS = YES
EXTRACT_LOCAL_METHODS = NO

# If this flag is set to YES, the members of anonymous namespaces will be
# extracted and appear in the documentation as a namespace called
@@ -486,7 +486,7 @@ EXTRACT_ANON_NSPACES = NO
# section is generated. This option has no effect if EXTRACT_ALL is enabled.
# The default value is: NO.

HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_MEMBERS = YES

# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy. If set
@@ -494,7 +494,7 @@ HIDE_UNDOC_MEMBERS = NO
# has no effect if EXTRACT_ALL is enabled.
# The default value is: NO.

HIDE_UNDOC_CLASSES = NO
HIDE_UNDOC_CLASSES = YES

# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
# (class|struct|union) declarations. If set to NO, these declarations will be
@@ -508,14 +508,14 @@ HIDE_FRIEND_COMPOUNDS = NO
# blocks will be appended to the function's detailed documentation block.
# The default value is: NO.

HIDE_IN_BODY_DOCS = NO
HIDE_IN_BODY_DOCS = YES

# The INTERNAL_DOCS tag determines if documentation that is typed after a
# \internal command is included. If the tag is set to NO then the documentation
# will be excluded. Set it to YES to include the internal documentation.
# The default value is: NO.

INTERNAL_DOCS = NO
INTERNAL_DOCS = YES

# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file
# names in lower-case letters. If set to YES, upper-case letters are also
@@ -607,7 +607,7 @@ SORT_GROUP_NAMES = NO
# list.
# The default value is: NO.

SORT_BY_SCOPE_NAME = NO
SORT_BY_SCOPE_NAME = YES

# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper
# type resolution of all parameters of a function it will reject a match between
@@ -708,7 +708,7 @@ LAYOUT_FILE =
# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
# the reference definitions. This must be a list of .bib files. The .bib
# extension is automatically appended if omitted. This requires the bibtex tool
# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info.
# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.
# For LaTeX the style of the bibliography can be controlled using
# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
# search path. See also \cite for info how to create references.
@@ -790,12 +790,12 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT =
INPUT = .

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
# documentation (see: https://www.gnu.org/software/libiconv/) for the list of
# documentation (see: http://www.gnu.org/software/libiconv) for the list of
# possible encodings.
# The default value is: UTF-8.

@@ -1043,7 +1043,7 @@ SOURCE_TOOLTIPS = YES
# If the USE_HTAGS tag is set to YES then the references to source code will
# point to the HTML generated by the htags(1) tool instead of doxygen built-in
# source browser. The htags tool is part of GNU's global source tagging system
# (see https://www.gnu.org/software/global/global.html). You will need version
# (see http://www.gnu.org/software/global/global.html). You will need version
# 4.8.6 or higher.
#
# To use it do the following:
@@ -1079,7 +1079,7 @@ VERBATIM_HEADERS = YES
# generated with the -Duse-libclang=ON option for CMake.
# The default value is: NO.

CLANG_ASSISTED_PARSING = NO
CLANG_ASSISTED_PARSING = YES

# If clang assisted parsing is enabled you can provide the compiler with command
# line options that you would normally use when invoking the compiler. Note that
@@ -1089,17 +1089,6 @@ CLANG_ASSISTED_PARSING = NO

CLANG_OPTIONS =

# If clang assisted parsing is enabled you can provide the clang parser with the
# path to the compilation database (see:
# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) used when the files
# were built. This is equivalent to specifying the "-p" option to a clang tool,
# such as clang-check. These options will then be pased to the parser.
# Note: The availability of this option depends on whether or not doxygen was
# generated with the -Duse-libclang=ON option for CMake.
# The default value is: 0.

CLANG_COMPILATION_DATABASE_PATH= 0

#---------------------------------------------------------------------------
# Configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
@@ -1218,7 +1207,7 @@ HTML_EXTRA_FILES =
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
# will adjust the colors in the style sheet and background images according to
# this color. Hue is specified as an angle on a colorwheel, see
# https://en.wikipedia.org/wiki/Hue for more information. For instance the value
# http://en.wikipedia.org/wiki/Hue for more information. For instance the value
# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
# purple, and 360 is red again.
# Minimum value: 0, maximum value: 359, default value: 220.
@@ -1254,17 +1243,6 @@ HTML_COLORSTYLE_GAMMA = 80

HTML_TIMESTAMP = NO

# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML
# documentation will contain a main index with vertical navigation menus that
# are dynamically created via Javascript. If disabled, the navigation index will
# consists of multiple levels of tabs that are statically embedded in every HTML
# page. Disable this option to support browsers that do not have Javascript,
# like the Qt help browser.
# The default value is: YES.
# This tag requires that the tag GENERATE_HTML is set to YES.

HTML_DYNAMIC_MENUS = YES

# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
# documentation will contain sections that can be hidden and shown after the
# page has loaded.
@@ -1288,12 +1266,12 @@ HTML_INDEX_NUM_ENTRIES = 100

# If the GENERATE_DOCSET tag is set to YES, additional index files will be
# generated that can be used as input for Apple's Xcode 3 integrated development
# environment (see: https://developer.apple.com/tools/xcode/), introduced with
# environment (see: http://developer.apple.com/tools/xcode/), introduced with
# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a
# Makefile in the HTML output directory. Running make will produce the docset in
# that directory and running make install will install the docset in
# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
# startup. See https://developer.apple.com/tools/creatingdocsetswithdoxygen.html
# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
# for more information.
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.
@@ -1409,7 +1387,7 @@ QCH_FILE =

# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
# Project output. For more information please see Qt Help Project / Namespace
# (see: http://doc.qt.io/qt-4.8/qthelpproject.html#namespace).
# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).
# The default value is: org.doxygen.Project.
# This tag requires that the tag GENERATE_QHP is set to YES.

@@ -1417,7 +1395,8 @@ QHP_NAMESPACE = org.doxygen.Project

# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
# Help Project output. For more information please see Qt Help Project / Virtual
# Folders (see: http://doc.qt.io/qt-4.8/qthelpproject.html#virtual-folders).
# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-
# folders).
# The default value is: doc.
# This tag requires that the tag GENERATE_QHP is set to YES.

@@ -1425,21 +1404,23 @@ QHP_VIRTUAL_FOLDER = doc

# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
# filter to add. For more information please see Qt Help Project / Custom
# Filters (see: http://doc.qt.io/qt-4.8/qthelpproject.html#custom-filters).
# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
# filters).
# This tag requires that the tag GENERATE_QHP is set to YES.

QHP_CUST_FILTER_NAME =

# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
# custom filter to add. For more information please see Qt Help Project / Custom
# Filters (see: http://doc.qt.io/qt-4.8/qthelpproject.html#custom-filters).
# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
# filters).
# This tag requires that the tag GENERATE_QHP is set to YES.

QHP_CUST_FILTER_ATTRS =

# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
# project's filter section matches. Qt Help Project / Filter Attributes (see:
# http://doc.qt.io/qt-4.8/qthelpproject.html#filter-attributes).
# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).
# This tag requires that the tag GENERATE_QHP is set to YES.

QHP_SECT_FILTER_ATTRS =
@@ -1532,7 +1513,7 @@ EXT_LINKS_IN_WINDOW = NO

FORMULA_FONTSIZE = 10

# Use the FORMULA_TRANSPARENT tag to determine whether or not the images
# Use the FORMULA_TRANPARENT tag to determine whether or not the images
# generated for formulas are transparent PNGs. Transparent PNGs are not
# supported properly for IE 6.0, but are supported on all modern browsers.
#
@@ -1544,7 +1525,7 @@ FORMULA_FONTSIZE = 10
FORMULA_TRANSPARENT = YES

# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
# https://www.mathjax.org) which uses client side Javascript for the rendering
# http://www.mathjax.org) which uses client side Javascript for the rendering
# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
# installed or if you want to formulas look prettier in the HTML output. When
# enabled you may also need to install MathJax separately and configure the path
@@ -1571,7 +1552,7 @@ MATHJAX_FORMAT = HTML-CSS
# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
# Content Delivery Network so you can quickly see the result without installing
# MathJax. However, it is strongly recommended to install a local copy of
# MathJax from https://www.mathjax.org before deployment.
# MathJax from http://www.mathjax.org before deployment.
# The default value is: http://cdn.mathjax.org/mathjax/latest.
# This tag requires that the tag USE_MATHJAX is set to YES.

@@ -1633,7 +1614,7 @@ SERVER_BASED_SEARCH = NO
#
# Doxygen ships with an example indexer (doxyindexer) and search engine
# (doxysearch.cgi) which are based on the open source search engine library
# Xapian (see: https://xapian.org/).
# Xapian (see: http://xapian.org/).
#
# See the section "External Indexing and Searching" for details.
# The default value is: NO.
@@ -1646,7 +1627,7 @@ EXTERNAL_SEARCH = NO
#
# Doxygen ships with an example indexer (doxyindexer) and search engine
# (doxysearch.cgi) which are based on the open source search engine library
# Xapian (see: https://xapian.org/). See the section "External Indexing and
# Xapian (see: http://xapian.org/). See the section "External Indexing and
# Searching" for details.
# This tag requires that the tag SEARCHENGINE is set to YES.

@@ -1833,7 +1814,7 @@ LATEX_SOURCE_CODE = NO

# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
# bibliography, e.g. plainnat, or ieeetr. See
# https://en.wikipedia.org/wiki/BibTeX and \cite for more info.
# http://en.wikipedia.org/wiki/BibTeX and \cite for more info.
# The default value is: plain.
# This tag requires that the tag GENERATE_LATEX is set to YES.

@@ -2016,9 +1997,9 @@ DOCBOOK_PROGRAMLISTING = NO
#---------------------------------------------------------------------------

# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures
# the structure of the code including all documentation. Note that this feature
# is still experimental and incomplete at the moment.
# AutoGen Definitions (see http://autogen.sf.net) file that captures the
# structure of the code including all documentation. Note that this feature is
# still experimental and incomplete at the moment.
# The default value is: NO.

GENERATE_AUTOGEN_DEF = NO
@@ -2231,7 +2212,7 @@ HIDE_UNDOC_RELATIONS = YES
# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent
# Bell Labs. The other options in this section have no effect if this option is
# set to NO
# The default value is: NO.
# The default value is: YES.

HAVE_DOT = NO

@@ -2387,7 +2368,9 @@ DIRECTORY_GRAPH = YES
# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order
# to make the SVG files visible in IE 9+ (other browsers do not have this
# requirement).
# Possible values are: png, jpg, gif, svg, png:gd, png:gd:gd, png:cairo,
# Possible values are: png, png:cairo, png:cairo:cairo, png:cairo:gd, png:gd,
# png:gd:gd, jpg, jpg:cairo, jpg:cairo:gd, jpg:gd, jpg:gd:gd, gif, gif:cairo,
# gif:cairo:gd, gif:gd, gif:gd:gd, svg, png:gd, png:gd:gd, png:cairo,
# png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and
# png:gdiplus:gdiplus.
# The default value is: png.


+ 14
- 16
include/utl/core/crtp.h 查看文件

@@ -1,21 +1,19 @@
/*!
* \file /utl/impl/crtp.h
* \file utl/impl/crtp.h
* \brief CRTP idiom support header
*
* 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/>.
* \copyright
* Copyright (C) 2018 Christos Choutouridis <christos@choutouridis.net>\n
* 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.\n
* 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.\n
* 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_impl_crtp_h__
@@ -25,7 +23,7 @@
/*!
* \defgroup crtp CRTP idiom support header
* \ingroup impl
* \ingroup core
*
* utl supports both CRTP idiom and dynamic polymorphism. By default
* CRTP is the preferred way. If the user need virtuals then instead of


+ 17
- 15
include/utl/core/impl.h 查看文件

@@ -1,30 +1,32 @@
/*!
* \file /utl/core/impl.h
* \file utl/core/impl.h
* \brief Implementation detail main forward header
*
* 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/>.
* \copyright
* Copyright (C) 2018 Christos Choutouridis <christos@choutouridis.net>\n
* 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.\n
* 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.\n
* 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_core_impl_h__
#define __utl_core_impl_h__
//! \defgroup core Core
//! Provide compiler feature support macros, uTL version,
//! global types etc...
// FWD include implementation details once
#include <utl/core/version.h>
#include <utl/core/types.h>
#include <utl/core/crtp.h>
#endif /* __utl_core_impl_h__ */

+ 18
- 18
include/utl/core/types.h 查看文件

@@ -1,23 +1,21 @@
/*!
* \file /utl/core/types.h
* \file utl/core/types.h
* \brief Basic type alias support
*
* 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/>.
*
* \copyright
* Copyright (C) 2018 Christos Choutouridis <christos@choutouridis.net>\n
* 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.\n
* 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.\n
* 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_core_types_h__
#define __utl_core_types_h__
@@ -27,13 +25,15 @@
//#include <type_traits>
namespace utl {
//! @{ \name byte and word types
//! \name byte and word types
//! @{
using byte_t = uint8_t; //!< 8 bits wide
using word_t = uint16_t; //!< 16 bits wide
using dword_t = uint32_t; //!< 32 bits wide
//! @}
//! @{ \name size and index
//! \name size and index
//! @{
using size_t = std::size_t;
using index_t = size_t; //!< index_t and size_t mend to be interchangeable


+ 52
- 32
include/utl/core/version.h 查看文件

@@ -1,46 +1,58 @@
/*!
* \file /utl/core/version.h
* \brief version and cpp version checks
* \file utl/core/version.h
* \brief utl version and cpp version checks
*
* 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 <http://www.gnu.org/licenses/>.
* \copyright
* Copyright (C) 2018 Christos Choutouridis <christos@choutouridis.net>\n
* 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.\n
* 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.\n
* 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_core_version_h__
#define __utl_core_version_h__
//!\defgroup version version
//! Definitions of the utl version
//!\addtogroup core
//! @{
//! \defgroup version Version
//! Definitions of the utl version and compiler features
//!@{
//! utl version
//! utl version as string
#define UTL_VERSION "0.1.0"
#define UTL_VERSION_MAJOR 0
#define UTL_VERSION_MINOR 1
#define UTL_VERSION_PATCH 0
//! utl version as integer
//!
//! This can be used in the user files to check for uTL versions.
//! The version number is constructed using:\n
//! ver = (Maj*10000 + Min*100 + Patch)
#define UTL_VERSION_VALUE ( (UTL_VERSION_MAJOR * 10000) \
+ (UTL_VERSION_MINOR * 100) \
+ UTL_VERSION_PATCH)
//! C++ versions
#define CXX_VER __cplusplus
#define CXX_VER_STD_11 201103L
#define CXX_VER_STD_14 201402L
#define CXX_VER_STD_17 201703L
//!@}
//! \name Compiler and feature checks
//! These checks are used inside uTL, but the user is free to use the as well.
//! @{
#define CXX_VER __cplusplus //!< Current compiler's version
#define CXX_VER_STD_11 201103L //!< C++11
#define CXX_VER_STD_14 201402L //!< C++14
#define CXX_VER_STD_17 201703L //!< C++17
//! Check for variable templates
//! \def CXX_VARIABLE_TEMPLATES
//! Check for variable templates (Non-zero if available)
#ifndef CXX_VARIABLE_TEMPLATES
#ifdef __cpp_variable_templates
#define CXX_VARIABLE_TEMPLATES __cpp_variable_templates
@@ -49,7 +61,8 @@
#endif
#endif
//! Check concepts
//! \def CXX_CONCEPTS
//! Check for concepts (Non-zero if available)
#ifndef CXX_CONCEPTS
#ifdef __cpp_concepts
#define CXX_CONCEPTS __cpp_concepts
@@ -58,7 +71,8 @@
#endif
#endif
//! Check for inline variables
//! \def CXX_INLINE_VARIABLES
//! Check for inline variables (Non-zero if available)
#ifndef CXX_INLINE_VARIABLES
#ifdef __cpp_inline_variables
#define CXX_INLINE_VARIABLES __cpp_inline_variables
@@ -67,6 +81,8 @@
#endif
#endif
//! \def CXX_FOLD_EXPRESSIONS
//! Check for fold expressions (Non-zero if available)
#ifndef CXX_FOLD_EXPRESSIONS
#ifdef __cpp_fold_expressions
#define CXX_FOLD_EXPRESSIONS __cpp_fold_expressions
@@ -75,19 +91,23 @@
#endif
#endif
/*
* Workaround inspections
*/
//! @}
//! \name Workaround inspections
//! @{
#if defined(__GNUC__) && (__GNUC__ < 5)
// https://wg21.link/cwg1558
#define UTL_WORKAROUND_CWG_1558
#endif
//! Base library requirement
#if CXX_VER < CXX_VER_STD_14
#error "uTL requires C++14"
#endif
//!@}
//! @}
//! @}
#endif /* #ifndef __utl_core_version_h__ */

+ 1
- 0
include/utl/dev/dev_iterators.h 查看文件

@@ -23,6 +23,7 @@
#include <utl/core/impl.h>
#include <utl/meta/meta.h>
#include <iterator>
namespace utl {


include/utl/meta/integral.h → include/utl/meta/basic.h 查看文件

@@ -1,24 +1,23 @@
/*!
* \file integralconstant.h
* \brief Template meta-programming integral constant
* \file utl/meta/basic.h
* \brief Template meta-programming basic definitions
*
* Copyright (C) 2018-2019 Christos Choutouridis
* \copyright
* Copyright (C) 2018 Christos Choutouridis <christos@choutouridis.net>\n
* 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.\n
* 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.\n
* 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/>.
*
* 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_integralconstant_h__
#define __utl_meta_integralconstant_h__
#ifndef __utl_meta_basic_h__
#define __utl_meta_basic_h__
#include <utl/core/impl.h>
#include <type_traits>
@@ -26,8 +25,8 @@
/*!
* \ingroup meta
* \defgroup integral
* integral constant support header
* \defgroup basic Basic
* Basic definitions
*/
//! @{
@@ -35,30 +34,39 @@ namespace utl {
namespace meta {
/*!
* Empty type
* meta's 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
* Each time someone applies \c \::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
//! Type alias for \c Tp::type. Used to evaluate/extract return type of metafunctions
template <typename Tp>
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.
//! Type alias for \c Tp::type. Used to evaluate/extract return value of metafunctions
template <typename Tp>
using eval_t = typename Tp::type;
//! Type alias for \c Tp::type. Used to evaluate/extract return type of metafunctions
template <typename Tp>
using eval_v = typename Tp::value;
//!
//! integral_ is a holder class for a compile-time value of an integral type.
//!
//! Every Integral Constant is also a null-ary Metafunction, returning itself.\n
//! An integral constant object is implicitly convertible to the corresponding
//! run-time value of the wrapped integral type
//! @{
template <typename Tp, Tp v>
using integral_ = std::integral_constant<Tp, v>;
//! @}
//! Wrappers for basic types
//! \name Wrappers for basic types
//! @{
//! bool_ type: integral constant wrapper for bool
@@ -123,7 +131,7 @@ namespace meta {
//! The last position we can express for indexing
using Npos = size_<index_t(-1)>;
//! integer sequence
//! \name integer sequence
//! @{
template< class Tp, Tp... Ints >
using integer_sequence = std::integer_sequence<Tp, Ints...>;
@@ -148,4 +156,4 @@ namespace meta {
//!@}
#endif /* __utl_meta_integralconstant_h__ */
#endif /* __utl_meta_basic_h__ */

+ 47
- 50
include/utl/meta/detection.h 查看文件

@@ -1,23 +1,21 @@
/*!
* \file detection.h
* \brief Detection idiom based on WG21's N4502 [\ref 1] from Walter E. Brown
* \brief Detection idiom based on WG21's \ref N4502 from Walter E. Brown
*
* Copyright (C) 2018-2019 Christos Choutouridis
* \copyright
* Copyright (C) 2018 Christos Choutouridis <christos@choutouridis.net>\n
* 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.\n
* 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.\n
* 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/>.
*
* 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/>.
*
* \anchor [1]: www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4502.pdf
* \anchor N4502 www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4502.pdf
*/
#ifndef __utl_meta_detection_h__
#define __utl_meta_detection_h__
@@ -37,7 +35,7 @@ namespace utl {
namespace meta {
/*!
* void_t meta-function that maps a sequence of any types to the type void
* \name void_t implementation
*/
//! @{
#if defined(UTL_WORKAROUND_CWG_1558)
@@ -47,18 +45,18 @@ namespace meta {
};
//! void_t type alias
template<typename... _Ts>
using void_t = eval<void_<_Ts...>>;
using void_t = eval_t<void_<_Ts...>>;
#else
//! void_ type alias
//! void_ meta-function that maps a sequence of any types to the type void
template <typename...> using void_ = void;
//! void_t type alias
//! void_t meta-function that maps a sequence of any types to the type void
template <typename...> using void_t = void;
#endif
//! @}
/*!
* Not a type to use in detected idiom. This type can
* not be constructed, destructed or copied
* not be constructed, destructed or copied.
*/
struct nat_ {
nat_() = delete;
@@ -67,9 +65,9 @@ namespace meta {
void operator = (nat_ const&) = delete;
};
//! Detector for detection idiom
//! \name Detector for detection idiom
//! @{
namespace detail {
namespace details {
template <typename Default,
typename AlwaysVoid,
template<typename...> class Op, typename... Args>
@@ -89,24 +87,23 @@ namespace meta {
template <typename Default,
template<typename...> class Op, typename... Args>
using detected_or = detector<Default, void, Op, Args...>;
} // namespace detail
} // namespace details
//! @}
/*!
* detection interface
* \name detection interface
*/
//! @{
/*!
* Checks if Op<Args...> is a valid expression without evaluating it.
*
* \tparam Op a meta-callback function to pass Args...
* \tparam Args... types to pass to Op for checking
* \tparam Op a meta-callback function to pass Args...
* \tparam Args... types to pass to Op for checking
* \return status of the operation [bool_]
* \arg true_ if Op<Args...> is valid expression
* \arg false_ if Op<Args...> is not valid
*
* \example
* \code
* // archetypal alias for a copy assignment operation
* template< class T > using copy_assign_t = decltype( declval<T&>() = declval<T const &>() );
@@ -115,7 +112,7 @@ namespace meta {
* \endcode
*/
template <template<typename...> class Op, typename... Args>
using is_detected = typename detail::detector<nat_, void, Op, Args...>::detected;
using is_detected = typename details::detector<nat_, void, Op, Args...>::detected;
//! Detection predicate
template< template<typename...> class Op, typename... Args>
@@ -124,12 +121,12 @@ namespace meta {
/*!
* Detection tool that evaluates to Op<Args...> if it's valid and to nat_ if not
*
* \param Op metafunction detector
* \param Args... The arguments to pass to \p Op and check if is well formed
* \tparam Op metafunction detector
* \tparam Args... The arguments to pass to \p Op and check if is well formed
* \return The result type
* \arg Op<Args...> if is well formed
* \arg nat_ if Op<Args...> is ill formed
* \example
*
* \code
* template <typename T> using try_type = typename T::type; // detector
* template <typename T> using try_ppT = decltype (++(std::declval<T>())); // detector
@@ -141,20 +138,20 @@ namespace meta {
* \endcode
*/
template <template<typename...> class Op, typename... Args>
using detected_t = eval <
detail::detector<nat_, void, Op, Args...>
using detected_t = eval_t <
details::detector<nat_, void, Op, Args...>
>;
/*!
* Detection tool that evaluates to Op<Args...> if it's valid and to \p Default if not
*
* \param Default The resulting type if detection fail
* \param Op metafunction detector
* \param Args... The arguments to pass to \p Op and check if is well formed
* \tparam Default The resulting type if detection fail
* \tparam Op metafunction detector
* \tparam Args... The arguments to pass to \p Op and check if is well formed
* \return The result type
* \arg Op<Args...> if is well formed
* \arg Default if Op<Args...> is ill formed
* \example
*
* \code
* template <typename T> using try_type = typename T::type; // detector
* template <typename T> using try_ppT = decltype (++(std::declval<T>())); // detector
@@ -167,21 +164,21 @@ namespace meta {
*/
template <typename Default,
template<typename...> class Op, typename... Args>
using detected_or_t = eval <
detail::detected_or<Default, Op, Args...>
using detected_or_t = eval_t <
details::detected_or<Default, Op, Args...>
>;
/*!
* Detection tool that evaluates to true_ if evaluation of Op<Args...>
* is \p Expected and to false_ if not
*
* \param Expected The expected resulting type if detection succeed
* \param Op metafunction detector
* \param Args... The arguments to pass to \p Op and check if is well formed
* \tparam Expected The expected resulting type if detection succeed
* \tparam Op metafunction detector
* \tparam Args... The arguments to pass to \p Op and check if is well formed
* \return The result type
* \arg true_ if Op<Args...> is well formed and evaluate to Expected
* \arg false_ Any other case
* \example
*
* \code
* template <typename T> using try_type = typename T::type; // detector
* template <typename T> using try_ppT = decltype (++(std::declval<T>())); // detector
@@ -194,7 +191,7 @@ namespace meta {
*/
template <typename Expected,
template<typename...> class Op, typename... Args >
using is_detected_exact = eval <
using is_detected_exact = eval_t <
same_<Expected, detected_t<Op, Args...>>
>;
@@ -207,13 +204,13 @@ namespace meta {
* Detection tool that evaluates to true_ if evaluation of Op<Args...> is convertible
* to \p To and to false_ if not
*
* \param To The to convert to if detection succeed
* \param Op metafunction detector
* \param Args... The arguments to pass to \p Op and check if is well formed
* \tparam To The to convert to if detection succeed
* \tparam Op metafunction detector
* \tparam Args... The arguments to pass to \p Op and check if is well formed
* \return The result type
* \arg true_ if Op<Args...> is well formed and convertible to To
* \arg false_ Any other case
* \example
*
* \code
* template <typename T> using try_type = typename T::type; // detector
* template <typename T> using try_ppT = decltype (++(std::declval<T>())); // detector
@@ -226,7 +223,7 @@ namespace meta {
*/
template <typename To,
template<typename...> class Op, typename... Args >
using is_detected_convertible = eval <
using is_detected_convertible = eval_t <
std::is_convertible< detected_t<Op, Args...>, To >
>;


+ 44
- 54
include/utl/meta/invoke.h 查看文件

@@ -2,54 +2,47 @@
* \file invoke.h
* \brief Template meta-programming utilities for callables
*
* 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 detail.
*
* 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/>.
* \copyright
* Copyright (C) 2018 Christos Choutouridis <christos@choutouridis.net>\n
* 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.\n
* 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.\n
* 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_invoke_h__
#define __utl_meta_invoke_h__
#include <utl/core/impl.h>
#include <utl/meta/integral.h>
#include <utl/meta/basic.h>
#include <utl/meta/detection.h>
#include <utl/meta/operations.h>
/*!
* \ingroup meta
* \defgroup invoke
* A meta-programming invoke() analogous. A \c meta::invocable shall contain a nested
* template type named \b apply which is bind to actual invocable meta-function.
*
* - We can use \c wrap<> or even better \c quote<> in order to wrap a metafunction to a type (metafunction class)
* - We can pass these wrapped types to other metafunctions
* - We can \c invoke<> the inner \c apply from a wrapped metafunction class.
*/
//! @{
namespace utl {
namespace meta{
/*!
* \name meta::invoke
*
* A meta-programming invoke() analogous. A \c meta::invocable shall contain a nested
* template type named \b apply which is bind to actual invocable meta-function.
*
* - We can use \c wrap<> or even better \c quote<> in order to wrap a metafunction to a type (metafunction class)
* - We can pass these wrapped types to other metafunctions
* - We can \c invoke<> the inner \c apply from a wrapped metafunction class.
* \name identity implementation
*/
//! @{
/*!
* identity, identity_t.
*/
//! @{
//! Identity is a metafunction always return the input type
template <typename _Tp>
struct identity {
#if defined (UTL_WORKAROUND_CWG_1558)
@@ -69,7 +62,7 @@ namespace meta{
//! @}
/*!
* invoke, invoke_t
* name invoke, invoke_t
*/
//! @{
/*!
@@ -88,7 +81,7 @@ namespace meta{
using invoke_t = eval< invoke <Fn, Args...>>;
//! @}
//! wrap
//! \name wrap
//! @{
/*!
* wrap is a higher-order primitive that wraps an n-ary Metafunction
@@ -111,9 +104,9 @@ namespace meta{
};
//! @}
//! Is applicable trait
//! \name Is applicable trait
//! @{
namespace detail {
namespace details {
template<template<typename...> class F, typename... T>
struct is_applicable_ {
@@ -159,26 +152,25 @@ namespace meta{
//! check if we can instantiate \p F with parameters \p T
template<template<typename...> class F, typename... T>
using is_applicable_t = eval<
detail::is_applicable_<F, T...>
details::is_applicable_<F, T...>
>;
//! check if we can invoke \p Q with parameters \p T
template<typename Q, typename... T>
using is_applicable_qt = eval <
detail::is_applicable_q_ <Q, T...>
details::is_applicable_q_ <Q, T...>
>;
//! check if we can instantiate \p F with parameters \p Is of type \p T
template <typename T, template<T...> class F, T... Is>
using is_applicable_it = eval<
detail::is_applicable_i_<T, F, Is...>
details::is_applicable_i_<T, F, Is...>
>;
//! @}
//! defer
//! \name defer
//! @{
namespace detail {
//! @{
namespace details {
template<template<typename...> class F, typename... Ts>
struct defer_ {
using type = F<Ts...>;
@@ -194,34 +186,33 @@ namespace meta{
//! template<template<typename...> class F, typename... Ts>
//! using defer_ = F<Ts...>;
//!
//! The use of struct here is due to Core issue 1430 [\ref link1 1] and is used
//! as suggested by Roy Crihfield in [\ref link2 2].
//! The use of struct here is due to Core issue 1430 \ref link1 and is used
//! as suggested by Roy Crihfield in \ref link2.
//! In short, this is due to language's inability to expand Ts... into
//! a fixed parameter list of an alias template.
//!
//! \anchor link1 [1]: https://wg21.link/cwg1430
//! \anchor link2 [2]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59498
//! @}
//! \anchor link1 https://wg21.link/cwg1430
//! \anchor link2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59498
}
//! defer alias template for F<Ts...>
template<template<class...> class F, class... Ts>
using defer = if_<
detail::is_applicable_<F, Ts...>,
detail::defer_<F, Ts...>,
details::is_applicable_<F, Ts...>,
details::defer_<F, Ts...>,
nil_ //!< Safe, nil_ is dereferencable
>;
//! defer_i alias template for F<T, Is...>
template <typename T, template<T...> class F, T... Is>
using defer_i = if_ <
detail::is_applicable_i_<T, F, Is...>,
detail::defer_i_<T, F, Is...>,
details::is_applicable_i_<T, F, Is...>,
details::defer_i_<T, F, Is...>,
nil_ //!< Safe, nil_ is dereferencable
>;
//! @}
//! quote
//! \name quote
//! @{
/*!
* quote deferred is a higher-order primitive that wraps an n-ary Metafunction
@@ -249,9 +240,9 @@ namespace meta{
};
//! @}
//! compose
//! \name compose
//! @{
namespace detail {
namespace details {
template <template <typename...> class... Fns> struct compose_f_ {};
// recursive call to all invokes
@@ -297,7 +288,7 @@ namespace meta{
* This implies from N invocables in \p Fns the first N-1 has to be unary.
* Thats because of the "return" type of metafunction. They can only return one
* type. So for n-ary invocables in the N-1 places the typelist<> is the solution.
* \example
*
* \code
* static_assert( std::is_same<
* invoke<compose<quote<F1>, quote<F2>, quote<F3>>, int>, F1<F2<F3<int>>>
@@ -305,7 +296,7 @@ namespace meta{
* \endcode
*/
template <typename... Fns>
using compose = detail::compose_<Fns...>;
using compose = details::compose_<Fns...>;
/*!
* Create an invocable from other metafunctions by composition.
@@ -313,7 +304,7 @@ namespace meta{
* This implies from N invocables in \p Fns the first N-1 has to be unary.
* Thats because of the "return" type of metafunction. They can only return one
* type. So for n-ary invocables in the N-1 places the typelist<> is the solution.
* \example
*
* \code
* static_assert( std::is_same<
* invoke<compose_f<F1, F2, F3>, int>, F1 <F2 <F3 <int>>>
@@ -321,7 +312,7 @@ namespace meta{
* \endcode
*/
template <template <typename...> class... Fns>
using compose_f = detail::compose_f_<Fns...>;
using compose_f = details::compose_f_<Fns...>;
//! @}
/*!
@@ -362,7 +353,6 @@ namespace meta{
}}
//! @}
//! @}
#endif /* __utl_meta_invoke_h__ */

+ 19
- 17
include/utl/meta/meta.h 查看文件

@@ -1,27 +1,29 @@
/*!
* \file /utl/meta/meta.h
* \brief Include all meta library
* \file utl/meta/meta.h
* \brief Meta library forward header
*
* 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 <http://www.gnu.org/licenses/>.
* \copyright
* Copyright (C) 2018 Christos Choutouridis <christos@choutouridis.net>\n
* 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.\n
* 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.\n
* 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_meta_h__
#define __utl_meta_meta_h__
#include <utl/meta/integral.h>
//! \defgroup meta Meta
//! An embedded metaprogramming library for uTL.
//!
#include <utl/meta/basic.h>
#include <utl/meta/selection.h>
#include <utl/meta/operations.h>
#include <utl/meta/useif.h>


+ 101
- 103
include/utl/meta/operations.h 查看文件

@@ -2,20 +2,18 @@
* \file operations.h
* \brief Integral constant operations and logical operations
*
* 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 <http://www.gnu.org/licenses/>.
* \copyright
* Copyright (C) 2018 Christos Choutouridis <christos@choutouridis.net>\n
* 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.\n
* 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.\n
* 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_operations_h__
#define __utl_meta_operations_h__
@@ -26,7 +24,7 @@
/*!
* \ingroup meta
* \defgroup logic
* \defgroup logic_operations Logic Operations
* logic operators and type relations support
*/
//! @{
@@ -34,81 +32,84 @@ namespace utl {
namespace meta{
/*!
* Logical relation for types
* \name Logical relation for types
*/
//! @{
//! Negate the *bool* constant parameter
//! Negate the *bool* constant parameter and return bool_
template <bool B>
using not_c = bool_<!B>;
//! not
template<typename _Tp>
using not_ = not_c<_Tp::type::value>;
//! negate the bool_ parameter and return bool_
template<typename Tp>
using not_ = not_c<Tp::type::value>;
//! OR implementation
//! \name OR implementation
//! @{
namespace detail {
namespace details {
template<typename...> struct _or_;
template<>
struct _or_<> : false_ { };
template<typename _T1>
struct _or_<_T1> : _T1 { };
template<typename T1>
struct _or_<T1> : T1 { };
template<typename _T1, typename _T2>
struct _or_ <_T1, _T2>
: if_<_T1, _T1, _T2> { };
template<typename T1, typename T2>
struct _or_ <T1, T2>
: if_<T1, T1, T2> { };
template<typename _T1, typename _T2, typename _T3, typename... _Tn>
struct _or_<_T1, _T2, _T3, _Tn...>
: if_<_T1, _T1, _or_<_T2, _T3, _Tn...>> { };
template<typename T1, typename T2, typename T3, typename... Tn>
struct _or_<T1, T2, T3, Tn...>
: if_<T1, T1, _or_<T2, T3, Tn...>> { };
}
template <typename... _Ts>
using or_ = eval<detail::_or_<_Ts...>>;
//! Operator or for bool_ types
//! \tparam Ts Variadic args of type bool_
//! \return Logical or as bool_
template <typename... Ts>
using or_ = eval_t<details::_or_<Ts...>>;
//! @}
//! AND implementation
//! \name AND implementation
//! @{
namespace detail {
namespace details {
template<typename...> struct _and_;
template<>
struct _and_<>
: true_ { };
template<typename _T1>
struct _and_ <_T1>
: _T1 { };
template<typename T1>
struct _and_ <T1>
: T1 { };
template<typename _T1, typename _T2>
struct _and_<_T1, _T2>
: if_<_T1, _T2, _T1> { };
template<typename T1, typename T2>
struct _and_<T1, T2>
: if_<T1, T2, T1> { };
template<typename _T1, typename _T2, typename _T3, typename... _Tn>
struct _and_<_T1, _T2, _T3, _Tn...>
: if_<_T1, _and_<_T2, _T3, _Tn...>, _T1> { };
template<typename T1, typename T2, typename T3, typename... Tn>
struct _and_<T1, T2, T3, Tn...>
: if_<T1, _and_<T2, T3, Tn...>, T1> { };
}
template <typename... _Ts>
using and_ = eval<detail::_and_<_Ts...>>;
//! Operator and for bool_ types
//! \tparam Ts Variadic args of type bool_
//! \return Logical and as bool_
template <typename... Ts>
using and_ = eval_t<details::_and_<Ts...>>;
//! @}
//! same
//! \name same
//! @{
template<typename _T1, typename _T2>
template<typename T1, typename T2>
struct same_ : false_ { };
template<typename _Tp>
struct same_ <_Tp, _Tp> : true_ { };
//! @}
template<typename Tp>
struct same_ <Tp, Tp> : true_ { };
//! not same
//! @{
template<typename _T1, typename _T2>
using not_same_ = not_<eval<same_<_T1, _T2>>>;
template<typename T1, typename T2>
using not_same_ = not_<eval_t<same_<T1, T2>>>;
//! @}
//! @}
@@ -119,8 +120,8 @@ namespace meta{
/*!
* \ingroup meta
* \defgroup integral operators
* Type arithmetic and operators
* \defgroup integral_operators integral operators
* Type arithmetic and operations
*/
//! @{
@@ -128,97 +129,94 @@ namespace utl {
namespace meta {
/*!
* Math operations
* requires IntegralConstant(_Tp)
* \name Math operations
*/
//! @{
//! Negation
template <typename _Tp>
using negate = integral_<decltype(-_Tp()), -_Tp()>;
template <typename Tp>
using negate = integral_<decltype(-Tp()), -Tp()>;
//! Addition
template <typename _Tp1, typename _Tp2>
template <typename Tp1, typename Tp2>
using add = integral_<
decltype(_Tp1() + _Tp2()),
_Tp1() + _Tp2()
decltype(Tp1() + Tp2()),
Tp1() + Tp2()
>;
//! Multiplication
template <typename _Tp1, typename _Tp2>
template <typename Tp1, typename Tp2>
using mult = integral_<
decltype(_Tp2() * _Tp2()),
_Tp1() * _Tp2()
decltype(Tp2() * Tp2()),
Tp1() * Tp2()
>;
//! Division
template <typename _Tp1, typename _Tp2>
template <typename Tp1, typename Tp2>
using divide = integral_<
decltype(_Tp2() / _Tp2()),
_Tp1() / _Tp2()
decltype(Tp2() / Tp2()),
Tp1() / Tp2()
>;
//! Modulo
template <typename _Tp1, typename _Tp2>
template <typename Tp1, typename Tp2>
using modulo = integral_<
decltype(_Tp1() % _Tp2()),
_Tp1() % _Tp2()
decltype(Tp1() % Tp2()),
Tp1() % Tp2()
>;
//! Substruction
template <typename _Tp1, typename _Tp2>
using sub = add<_Tp1, negate<_Tp2>>;
template <typename Tp1, typename Tp2>
using sub = add<Tp1, negate<Tp2>>;
//! Increase
template <typename _Tp>
using inc = add<_Tp, int_<1>>;
template <typename Tp>
using inc = add<Tp, int_<1>>;
//! decrease
template <typename _Tp>
using dec = add<_Tp, int_<-1>>;
template <typename Tp>
using dec = add<Tp, int_<-1>>;
//! @}
/*!
* Comparison operations
* requires IntegralConstant(_Tp)
* \name Comparison operations
*/
//! @{
//! \return a true-valued Integral Constant if _Tp1 and _Tp2 are equal.
template <typename _Tp1, typename _Tp2> using comp_eq = bool_<_Tp1() == _Tp2()>;
//! \return a true-valued Integral Constant if _Tp1 is less than _Tp2.
template <typename _Tp1, typename _Tp2> using comp_lt = bool_<(_Tp1() < _Tp2())>;
//! \return a true-valued Integral Constant if Tp1 and Tp2 are equal.
template <typename Tp1, typename Tp2> using comp_eq = bool_<Tp1() == Tp2()>;
//! \return a true-valued Integral Constant if Tp1 is less than Tp2.
template <typename Tp1, typename Tp2> using comp_lt = bool_<(Tp1() < Tp2())>;
//! Not equal
template <typename _Tp1, typename _Tp2> using comp_ne = not_<comp_eq<_Tp1, _Tp2>>;
template <typename Tp1, typename Tp2> using comp_ne = not_<comp_eq<Tp1, Tp2>>;
//! Greater than
template <typename _Tp1, typename _Tp2> using comp_gt = comp_lt <_Tp2, _Tp1>;
template <typename Tp1, typename Tp2> using comp_gt = comp_lt <Tp2, Tp1>;
//! Less or equal
template <typename _Tp1, typename _Tp2> using comp_le = not_<comp_lt<_Tp2, _Tp1>>;
template <typename Tp1, typename Tp2> using comp_le = not_<comp_lt<Tp2, Tp1>>;
//! Greater or equal
template <typename _Tp1, typename _Tp2> using comp_ge = not_<comp_lt<_Tp1, _Tp2>>;
template <typename Tp1, typename Tp2> using comp_ge = not_<comp_lt<Tp1, Tp2>>;
//! @}
/*!
* Bitwise operations
* requires IntegralConstant(_Tp)
* \name Bitwise operations
*/
//! @{
//! \return bitwise not (~) operation of its argument.
template <typename _T> using bitnot_ = integral_<typename _T::value_type, (typename _T::value_type)(~_T())>;
template <typename T> using bitnot_ = integral_<typename T::valueType, (typename T::valueType)(~T())>;
//! \return bitwise and (&) operation of its arguments
template <typename _Tp1, typename _Tp2>
using bitand_ = integral_<decltype(_Tp1() & _Tp2()), _Tp1() & _Tp2()>;
template <typename Tp1, typename Tp2>
using bitand_ = integral_<decltype(Tp1() & Tp2()), Tp1() & Tp2()>;
//! \return bitwise or (|) operation of its arguments.
template <typename _Tp1, typename _Tp2>
using bitor_ = integral_<decltype(_Tp1() | _Tp2()), _Tp1() | _Tp2()>;
template <typename Tp1, typename Tp2>
using bitor_ = integral_<decltype(Tp1() | Tp2()), Tp1() | Tp2()>;
//! \return bitwise xor (^) operation of its arguments.
template <typename _Tp1, typename _Tp2>
using bitxor_ = integral_<decltype(_Tp1() ^ _Tp2()), _Tp1() ^ _Tp2()>;
//! \return the result of bitwise shift left (<<) operation on _Tp.
template <typename _Tp, typename shift>
using shift_left = integral_<typename _Tp::value_type, (typename _Tp::value_type)(_Tp() << shift())>;
//! \return the result of bitwise shift right (>>) operation on _Tp.
template <typename _Tp, typename shift>
using shift_right = integral_<typename _Tp::value_type, (typename _Tp::value_type)(_Tp() >> shift())>;
template <typename Tp1, typename Tp2>
using bitxor_ = integral_<decltype(Tp1() ^ Tp2()), Tp1() ^ Tp2()>;
//! \return the result of bitwise shift left (<<) operation on Tp.
template <typename Tp, typename shift>
using shift_left = integral_<typename Tp::value_type, (typename Tp::value_type)(Tp() << shift())>;
//! \return the result of bitwise shift right (>>) operation on Tp.
template <typename Tp, typename shift>
using shift_right = integral_<typename Tp::value_type, (typename Tp::value_type)(Tp() >> shift())>;
//! @}
}}
//!@}


+ 19
- 26
include/utl/meta/selection.h 查看文件

@@ -2,47 +2,40 @@
* \file selection.h
* \brief Template meta-programming type selections.
*
* 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 <http://www.gnu.org/licenses/>.
* \copyright
* Copyright (C) 2018 Christos Choutouridis <christos@choutouridis.net>\n
* 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.\n
* 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.\n
* 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_selection_h__
#define __utl_meta_selection_h__
#include <utl/core/impl.h>
#include <utl/meta/integral.h>
#include <utl/meta/basic.h>
/*!
* \ingroup meta
* \defgroup type selection
* \defgroup selection Selection
* Type selection support header
*/
//! @{
namespace utl {
namespace meta{
/*!
* Type selection
*/
//! @{
//! if_, if_c
//! \name if implementation
//! @{
namespace detail {
namespace details {
template <bool If, typename...>
struct if_c_ {
using type = nil_; //!< avoid ill formed result
using type = nil_; //< avoid ill formed result
};
template<typename Then>
struct if_c_<true, Then> {
@@ -59,7 +52,7 @@ namespace meta{
}
//! Select one type or another depending on a compile-time Boolean.
template <bool B, typename... Args>
using if_c = eval<detail::if_c_<B, Args...>>;
using if_c = eval_t<details::if_c_<B, Args...>>;
//! Select one type or another depending on a compile-time Boolean type
template <typename If, typename... Args>
@@ -68,7 +61,7 @@ namespace meta{
//! @}
/*!
* Named type selectors
* \name Named type selectors
*/
//! @{


+ 20
- 21
include/utl/meta/sfinae.h 查看文件

@@ -2,20 +2,18 @@
* \file sfinae.h
* \brief Template meta-programming SFINAE helpers
*
* 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 <http://www.gnu.org/licenses/>.
* \copyright
* Copyright (C) 2018 Christos Choutouridis <christos@choutouridis.net>\n
* 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.\n
* 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.\n
* 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_sfinae_h__
#define __utl_meta_sfinae_h__
@@ -25,42 +23,43 @@
/*!
* \ingroup meta
* \defgroup sfinae
* \defgroup sfinae sfinae
* conditional use support header.
*/
//! @{
namespace utl {
namespace meta {
//! Tool to enable a partial specialization only if a boolean condition is true.
//! \name when implementation
//! @{
namespace detail {
namespace details {
// template <typename... T>
// struct dev_null { using type = dev_null; }; //< Same as typelist
template <bool If> struct when_ { };
template <> struct when_<true> { using type = void; };
}
//! Tool to enable a partial specialization only if a boolean condition is true.
//! Well formed only if \p If is true
template <bool If>
using when = eval< detail::when_<If> >;
using when = eval_t< details::when_<If> >;
// //! Well formed only if all of \p Ifs are \c true
// template <bool ...Ifs>
// using when_all = detail::dev_null<
// using when_all = details::dev_null<
// when<Ifs>...
// >;
//! @}
//! enable_if
//! \name enable_if from STL
//! @{
//! enable_if, imported from stl
template <bool If, typename _Tp = void> using enable_if = std::enable_if<If, _Tp>;
//! alias template for enable_if
template<bool If, typename _Tp = void> using enable_if_t = eval< enable_if<If, _Tp> >;
template<bool If, typename _Tp = void> using enable_if_t = eval_t< enable_if<If, _Tp> >;
//! @}


+ 27
- 27
include/utl/meta/typelist.h 查看文件

@@ -2,26 +2,25 @@
* \file typelist.h
* \brief A template parameter "container"
*
* Copyright (C) 2018-2019 Christos Choutouridis
* \copyright
* Copyright (C) 2018 Christos Choutouridis <christos@choutouridis.net>\n
* 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.\n
* 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.\n
* 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/>.
*
* 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_typelist_h__
#define __utl_meta_typelist_h__
#include <utl/core/impl.h>
#include <utl/meta/integral.h>
#include <utl/meta/basic.h>
#include <utl/meta/detection.h>
#include <utl/meta/invoke.h>
#include <utl/meta/sfinae.h>
@@ -38,28 +37,29 @@ namespace meta {
* \brief
* A class template that just holds a parameter pack.
*
* The idea came from MPL's sequence concept [\ref link1 1] and from N4115 [\ref link2 2].
* In addition to N4115's name "packer" we just prefer a name which is object, not a subject.
* This way the name gives the feeling of a container and smells like Python.
* The idea came from MPL's sequence concept \ref link1 and from N4115 \ref link2.
* In addition to N4115's name "packer" we just prefer a name which is an object, not a subject.
* This way the name gives the feeling of a container and smells like Python.\n
*
* In addition to tuple we lack members, so typelist could serve as an empty base class,
* and an object of the ultimate type could always be instantiated
* (even if the parameter typelist contains void or some type that lacks
* a default constructor).
* \example
* a default constructor).\n
*
* \code
* using l1 = typelist<int, void*, double, void>;
* l1 a {};
* \endcode
*
* boost::hana [\ref link3 3] suggests a more powerful scheme were type invariant structures can be used
* boost::hana \ref link3 suggests a more powerful scheme were type invariant structures can be used
* for metaprograming also. This lib does not need (yet) this kind of power (we afraid the
* responsibility that comes along). So a simple python-like list with some extra vector-like
* responsibility that comes along).\n
* So a simple python-like list with some extra vector-like
* element access functionalities and no iterators is good enough(for now).
*
* \anchor link1 [1]: https://www.boost.org/doc/
* \anchor link2 [2]: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4115.html
* \anchor link3 [3]: https://github.com/boostorg/hana
* \anchor link1 https://www.boost.org/doc/ \n
* \anchor link2 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4115.html \n
* \anchor link3 https://github.com/boostorg/hana \n
*/
template <typename... Ts>
struct typelist {
@@ -102,7 +102,7 @@ namespace meta {
public:
/*!
* Generate typelist<Ts..., Ts..., ...> of size \c N arguments.
* \example
*
* \code
* static_assert (
* std::is_same<typelist<int, char>::times<2>,
@@ -206,7 +206,7 @@ namespace meta {
*/
//! at: random element access
//! @{
namespace at_impl {
namespace details {
template <typename T> struct _add_pointer { using type = T*; };
template <typename T> using add_pointer = eval < _add_pointer <T> >;
@@ -241,7 +241,7 @@ namespace meta {
*/
template <typename List, index_t N>
using at_c = eval<
at_impl::at_<List, N>
details::at_<List, N>
>;
/*!


+ 23
- 25
include/utl/meta/useif.h 查看文件

@@ -2,20 +2,19 @@
* \file useif.h
* \brief Template meta-programming SFINAE helpers
*
* Copyright (C) 2018 Christos Choutouridis
* \copyright
* Copyright (C) 2018 Christos Choutouridis <christos@choutouridis.net>\n
* 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.\n
* 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.\n
* 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/>.
*
* 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_useif_h__
#define __utl_meta_useif_h__
@@ -26,33 +25,32 @@
/*!
* \ingroup meta
* \defgroup sfinae
* conditional use support header. This is a SFINAE wrapper
* \addtogroup sfinae
*/
//! @{
namespace utl {
namespace meta {
//! If same type resolves to _Ret, else SFINAE
template <typename _T1, typename _T2, typename _Ret =_T1>
//! If same type resolves to Ret, else SFINAE
template <typename T1, typename T2, typename Ret =T1>
using use_if_same_t = enable_if_t<
same_<_T1, _T2>::value, _Ret
eval_v<same_<T1, T2>>, Ret
>;
//! If not same type resolves to _Ret, else SFINAE
template <typename _T1, typename _T2, typename _Ret =_T1>
//! If not same type resolves to Ret, else SFINAE
template <typename T1, typename T2, typename Ret =T1>
using use_if_not_same_t = enable_if_t<
!same_<_T1, _T2>::value, _Ret
eval_v<not_same_<T1, T2>>, Ret
>;
//! If any type (_T1 or _T2) type resolves to _Ret, else to SFINAE
//! If any type (T1 or T2) type resolves to Ret, else to SFINAE
template <typename T1, typename... Ts>
using use_if_any_t = enable_if_t<
or_<T1, Ts...>::value, T1
eval_v<or_<T1, Ts...>>, T1
>;
//! If both type (_T1 and _T2) type resolves to _Ret, else to SFINAE
//! If both type (T1 and T2) type resolves to Ret, else to SFINAE
template <typename T1, typename... Ts>
using use_if_all_t = enable_if_t<
and_<T1, Ts...>::value, T1
eval_v<and_<T1, Ts...>>, T1
>;
}}


正在加载...
取消
保存