From c7050f28bfb05db8501bbdfc289351e81898001f Mon Sep 17 00:00:00 2001 From: Christos Choutouridis Date: Tue, 6 Oct 2020 23:24:31 +0300 Subject: [PATCH] WIP: documentation setup --- Doxyfile | 2 +- Doxypress | 486 ---------------------------------- include/utl/concepts/stl.h | 16 -- include/utl/core/crtp.h | 14 - include/utl/core/impl.h | 14 - include/utl/core/types.h | 13 - include/utl/core/version.h | 14 - include/utl/meta/basic.h | 302 +++++++++++++++++++-- include/utl/meta/detection.h | 31 +-- include/utl/meta/invoke.h | 36 ++- include/utl/meta/meta.h | 47 ++-- include/utl/meta/operations.h | 225 ---------------- include/utl/meta/selection.h | 79 ------ include/utl/meta/sfinae.h | 55 ++-- include/utl/meta/typelist.h | 188 ++++++------- include/utl/meta/useif.h | 60 ----- include/utl/utility/invoke.h | 21 +- 17 files changed, 464 insertions(+), 1139 deletions(-) delete mode 100644 Doxypress delete mode 100644 include/utl/meta/operations.h delete mode 100644 include/utl/meta/selection.h delete mode 100644 include/utl/meta/useif.h diff --git a/Doxyfile b/Doxyfile index c886e6e..40dbb62 100644 --- a/Doxyfile +++ b/Doxyfile @@ -1087,7 +1087,7 @@ CLANG_ASSISTED_PARSING = YES # specified with INPUT and INCLUDE_PATH. # This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. -CLANG_OPTIONS = +CLANG_OPTIONS = -I../include #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index diff --git a/Doxypress b/Doxypress deleted file mode 100644 index 1c58950..0000000 --- a/Doxypress +++ /dev/null @@ -1,486 +0,0 @@ -{ - "clang": { - "clang-compilation-path": "", - "clang-dialect": "-std=c++14", - "clang-flags": [ - "" - ], - "clang-parsing": false, - "clang-use-headers": true - }, - "configuration": { - "allow-sub-grouping": true, - "allow-unicode-names": false, - "always-detailed-sec": false, - "auto-link": true, - "brief-member-desc": true, - "built-in-stl-support": false, - "case-sensitive-fname": true, - "cpp-cli-support": false, - "create-subdirs": false, - "duplicate-docs": false, - "enabled-sections": [ - "" - ], - "extract-all": false, - "extract-anon-namespaces": false, - "extract-local-classes": true, - "extract-local-methods": false, - "extract-package": false, - "extract-private": false, - "extract-static": false, - "file-version-filter": "", - "force-local-includes": false, - "full-path-names": true, - "generate-bug-list": true, - "generate-deprecate-list": true, - "generate-test-list": true, - "generate-todo-list": true, - "group-nested-compounds": false, - "hide-compound-ref": false, - "hide-friend-compounds": false, - "hide-in-body-docs": false, - "hide-navtree-members": false, - "hide-scope-names": false, - "hide-undoc-classes": true, - "hide-undoc-members": true, - "idl-support": true, - "inherit-docs": true, - "inline-grouped-classes": false, - "inline-info": true, - "inline-inherited-member": false, - "inline-simple-struct": false, - "internal-docs": false, - "javadoc-auto-brief": false, - "language-mapping": [ - "" - ], - "layout-file": "", - "main-page-name": "", - "main-page-omit": false, - "markdown": true, - "max-init-lines": 30, - "multiline-cpp-brief": false, - "ns-alias": [ - "" - ], - "qt-auto-brief": false, - "repeat-brief": true, - "separate-member-pages": false, - "short-names": false, - "show-file-page": true, - "show-grouped-members-inc": false, - "show-include-files": true, - "show-namespace-page": true, - "show-used-files": true, - "sip-support": false, - "sort-brief-docs": false, - "sort-by-scope-name": false, - "sort-class-case-sensitive": false, - "sort-constructors-first": true, - "sort-group-names": false, - "sort-member-docs": true, - "strict-sig-matching": false, - "tcl-subst": [ - "" - ], - "toc-include-headers": 0, - "use-typedef-name": false - }, - "dot": { - "class-diagrams": true, - "dia-file-dirs": [ - "" - ], - "dia-path": "", - "directory-graph": true, - "dot-call": false, - "dot-called-by": false, - "dot-class-graph": true, - "dot-cleanup": true, - "dot-collaboration": true, - "dot-file-dirs": [ - "" - ], - "dot-font-name": "Helvetica", - "dot-font-path": "", - "dot-font-size": 10, - "dot-graph-max-depth": 0, - "dot-graph-max-nodes": 50, - "dot-hierarchy": true, - "dot-image-format": "png", - "dot-include": true, - "dot-included-by": true, - "dot-multiple-targets": false, - "dot-num-threads": 0, - "dot-path": "", - "dot-transparent": false, - "generate-legend": true, - "group-graphs": true, - "have-dot": false, - "hide-undoc-relations": true, - "interactive-svg": false, - "msc-file-dirs": [ - "" - ], - "mscgen-path": "", - "plantuml-cfg-file": "", - "plantuml-inc-path": [ - "" - ], - "plantuml-jar-path": "", - "template-relations": false, - "uml-limit-num-fields": 10, - "uml-look": false - }, - "doxypress-format": 1, - "doxypress-updated": "2018-Jun-30", - "external": { - "all-externals": false, - "external-groups": true, - "external-pages": true, - "generate-tagfile": "", - "perl-path": "/usr/bin/perl", - "tag-files": [ - "" - ] - }, - "general": { - "abbreviate-brief": [ - "The $name class", - "The $name widget", - "The $name file", - "is", - "provides", - "specifies", - "contains", - "represents", - "a", - "an", - "the" - ], - "aliases": [ - "" - ], - "lookup-cache-size": 0, - "optimize-c": false, - "optimize-cplus": true, - "optimize-fortran": false, - "optimize-java": false, - "optimize-python": false, - "output-dir": "doc", - "output-language": "English", - "strip-from-inc-path": [ - "" - ], - "strip-from-path": [ - "" - ], - "tab-size": 4 - }, - "index": { - "alpha-index": true, - "cols-in-index": 5, - "ignore-prefix": [ - "" - ] - }, - "input": { - "example-patterns": [ - "*" - ], - "example-recursive": false, - "example-source": [ - "" - ], - "exclude-files": [ - "" - ], - "exclude-patterns": [ - "" - ], - "exclude-symbols": [ - "" - ], - "exclude-symlinks": false, - "filter-patterns": [ - "" - ], - "filter-program": "", - "filter-source-files": false, - "filter-source-patterns": [ - "" - ], - "image-path": [ - "" - ], - "input-encoding": "UTF-8", - "input-patterns": [ - "*.as", - "*.c", - "*.cc", - "*.cpp", - "*.cxx", - "*.c++", - "*.cs", - "*.d", - "*.ddl", - "*.dox", - "*.for", - "*.f", - "*.f90", - "*.h", - "*.hh", - "*.hxx", - "*.hpp", - "*.h++", - "*.idl", - "*.ii", - "*.ixx", - "*.ipp", - "*.i++", - "*.inc", - "*.inl", - "*.java", - "*.js", - "*.m", - "*.md", - "*.mm", - "*.markdown", - "*.odl", - "*.php", - "*.php3", - "*.php4", - "*.php5", - "*.phtml", - "*.py", - "*.pyw", - "*.qsf", - "*.tcl", - "*.ucf" - ], - "input-recursive": true, - "input-source": [ - "include/utl" - ], - "mdfile-mainpage": "" - }, - "messages": { - "quiet": false, - "warn-doc-error": true, - "warn-format": "$file:$line: $text", - "warn-logfile": "", - "warn-undoc": true, - "warn-undoc-param": false, - "warnings": true - }, - "output-chm": { - "binary-toc": false, - "chm-file": "", - "chm-index-encoding": "", - "generate-chi": false, - "generate-chm": true, - "hhc-location": "", - "toc-expanded": false - }, - "output-docbook": { - "docbook-output": "docbook", - "docbook-program-listing": false, - "generate-docbook": false - }, - "output-docset": { - "docset-bundle-id": "org.doxypress.Project", - "docset-feedname": "DoxyPress generated docs", - "docset-publisher-id": "org.doxypress.Publisher", - "docset-publisher-name": "Publisher", - "generate-docset": false - }, - "output-eclipse": { - "eclipse-doc-id": "org.doxypress.Project", - "generate-eclipse": false - }, - "output-html": { - "disable-index": false, - "enum-values-per-line": 4, - "external-links-in-window": false, - "formula-fontsize": 10, - "formula-transparent": true, - "generate-html": true, - "generate-treeview": false, - "ghostscript": "", - "html-colorstyle-gamma": 80, - "html-colorstyle-hue": 220, - "html-colorstyle-sat": 100, - "html-dynamic-sections": false, - "html-extra-files": [ - "" - ], - "html-file-extension": ".html", - "html-footer": "", - "html-header": "", - "html-index-num-entries": 100, - "html-output": "html", - "html-search": false, - "html-stylesheets": [ - "" - ], - "html-timestamp": true, - "mathjax-codefile": "", - "mathjax-extensions": [ - "" - ], - "mathjax-format": "HTML-CSS", - "mathjax-relpath": "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/", - "search-data-file": "searchdata.xml", - "search-external": false, - "search-external-id": "", - "search-external-url": "", - "search-mappings": [ - "" - ], - "search-server-based": false, - "treeview-width": 250, - "use-mathjax": false - }, - "output-latex": { - "cite-bib-files": [ - "" - ], - "generate-latex": false, - "latex-batch-mode": false, - "latex-bib-style": "plain", - "latex-cmd-name": "latex", - "latex-compact": false, - "latex-extra-files": [ - "" - ], - "latex-extra-packages": [ - "" - ], - "latex-footer": "", - "latex-header": "", - "latex-hide-indices": false, - "latex-hyper-pdf": true, - "latex-output": "latex", - "latex-paper-type": "a4", - "latex-pdf": true, - "latex-ps": true, - "latex-source-code": false, - "latex-stylesheets": [ - "" - ], - "latex-timestamp": false, - "make-index-cmd-name": "makeindex" - }, - "output-man": { - "generate-man": false, - "man-extension": ".3", - "man-links": false, - "man-output": "man", - "man-subdir": "" - }, - "output-perl": { - "generate-perl": false, - "perl-latex": false, - "perl-prefix": "", - "perl-pretty": true - }, - "output-qhelp": { - "generate-qthelp": false, - "qch-file": "", - "qhp-cust-attrib": [ - "" - ], - "qhp-cust-filter-name": "", - "qhp-namespace": "org.doxypress.Project", - "qhp-sect-attrib": [ - "" - ], - "qhp-virtual-folder": "doc", - "qthelp-gen-path": "" - }, - "output-rtf": { - "generate-rtf": false, - "rtf-compact": false, - "rtf-extension": "", - "rtf-hyperlinks": false, - "rtf-output": "rtf", - "rtf-paper-type": "a4", - "rtf-source-code": false, - "rtf-stylesheet": "" - }, - "output-xml": { - "generate-xml": false, - "xml-output": "xml", - "xml-program-listing": true - }, - "preprocessor": { - "enable-preprocessing": false, - "expand-as-defined": [ - "" - ], - "expand-only-predefined": false, - "include-path": [ - "" - ], - "include-patterns": [ - "" - ], - "macro-expansion": false, - "predefined-macros": [ - "" - ], - "search-includes": true, - "skip-function-macros": true - }, - "project": { - "project-brief": "micro Template Library", - "project-logo": "", - "project-name": "uTL", - "project-version": "" - }, - "source": { - "inline-source": true, - "ref-by-relation": false, - "ref-link-source": true, - "ref-relation": false, - "source-code": true, - "source-tooltips": true, - "strip-code-comments": true, - "suffix-exclude-navtree": [ - "doc", - "dox", - "md", - "markdown", - "txt" - ], - "suffix-header-navtree": [ - "h", - "hh", - "hxx", - "hpp", - "h++", - "idl", - "ddl", - "pidl" - ], - "suffix-source-navtree": [ - "c", - "cc", - "cxx", - "cpp", - "c++", - "ii", - "ixx", - "ipp", - "i++", - "inl", - "java", - "m", - "mm", - "xml" - ], - "use-htags": false, - "verbatim-headers": true - } -} diff --git a/include/utl/concepts/stl.h b/include/utl/concepts/stl.h index edde000..35357d7 100644 --- a/include/utl/concepts/stl.h +++ b/include/utl/concepts/stl.h @@ -1,22 +1,6 @@ /*! * \file /utl/concepts/stl.h * \brief STL's Concepts - * - * 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_concepts_stl_h__ #define __utl_concepts_stl_h__ diff --git a/include/utl/core/crtp.h b/include/utl/core/crtp.h index 37d257a..f10708e 100644 --- a/include/utl/core/crtp.h +++ b/include/utl/core/crtp.h @@ -1,20 +1,6 @@ /*! * \file utl/impl/crtp.h * \brief CRTP idiom support header - * - * \copyright - * Copyright (C) 2018 Christos Choutouridis \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 . - * */ #ifndef __utl_impl_crtp_h__ #define __utl_impl_crtp_h__ diff --git a/include/utl/core/impl.h b/include/utl/core/impl.h index 3c3e1d4..3ce467f 100644 --- a/include/utl/core/impl.h +++ b/include/utl/core/impl.h @@ -1,20 +1,6 @@ /*! * \file utl/core/impl.h * \brief Implementation detail main forward header - * - * \copyright - * Copyright (C) 2018 Christos Choutouridis \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 . - * */ #ifndef __utl_core_impl_h__ #define __utl_core_impl_h__ diff --git a/include/utl/core/types.h b/include/utl/core/types.h index 79010c2..9732e64 100644 --- a/include/utl/core/types.h +++ b/include/utl/core/types.h @@ -1,19 +1,6 @@ /*! * \file utl/core/types.h * \brief Basic type alias support - * - * \copyright - * Copyright (C) 2018 Christos Choutouridis \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 . */ #ifndef __utl_core_types_h__ diff --git a/include/utl/core/version.h b/include/utl/core/version.h index 7b70d01..c2d4ab9 100644 --- a/include/utl/core/version.h +++ b/include/utl/core/version.h @@ -1,20 +1,6 @@ /*! * \file utl/core/version.h * \brief utl version and cpp version checks - * - * \copyright - * Copyright (C) 2018 Christos Choutouridis \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 . - * */ #ifndef __utl_core_version_h__ #define __utl_core_version_h__ diff --git a/include/utl/meta/basic.h b/include/utl/meta/basic.h index 97f1182..e0dfc30 100644 --- a/include/utl/meta/basic.h +++ b/include/utl/meta/basic.h @@ -1,20 +1,6 @@ /*! * \file utl/meta/basic.h * \brief Template meta-programming basic definitions - * - * \copyright - * Copyright (C) 2018 Christos Choutouridis \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 . - * */ #ifndef __utl_meta_basic_h__ #define __utl_meta_basic_h__ @@ -30,6 +16,13 @@ */ //! @{ +/*! + * \ingroup basic + * \defgroup meta_core Core + * Core definitions + */ +//! @{ + namespace utl { namespace meta { @@ -44,19 +37,21 @@ namespace meta { using type = nil_; }; - //! Type alias for \c Tp::type. Used to evaluate/extract return type of metafunctions + //! Type alias for \c Tp::type. + //! Is used to evaluate/extract return type of metafunctions //! \tparam Tp The metafunction to evaluate //! \return The inner \::type template using eval = typename Tp::type; - //! Type alias for \c Tp::type. Used to evaluate/extract return type of metafunctions + //! Type alias for \c Tp::type::value. + //! Is used to evaluate/extract return value of metafunctions + //! \tparam Tp The metafunction to evaluate + //! \return The inner \::type::value template - using eval_t = typename Tp::type; + using eval_v = typename eval::value; + - //! Type alias for \c Tp::value. Used to evaluate/extract return value of metafunctions - template - using eval_v = typename Tp::value; //! //! integral_ is a holder class for a compile-time value of an integral type. @@ -119,6 +114,13 @@ namespace meta { template using size_ = integral_; + //! The last position we can express for indexing + using Npos = size_; + //! @} + + //! \name unevaluated expressions + //! @{ + //! Computes the size of the type \p Tp. //! Complexity \f$ O(1) \f$. template @@ -130,9 +132,6 @@ namespace meta { using alignof_ = size_; //! @} - //! The last position we can express for indexing - using Npos = size_; - //! \name integer sequence //! @{ template< class Tp, Tp... Ints > @@ -152,10 +151,265 @@ namespace meta { //! Alias template index_sequence_for template using index_sequence_for = make_index_sequence; - //! @} }} //!@} +/*! + * \ingroup basic + * \defgroup selection Selection + * Type selection support header + */ +//! @{ +namespace utl { +namespace meta{ + + //! \name if implementation + //! @{ + namespace details { + 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 = eval>; + + //! Select one type or another depending on a compile-time Boolean type + template + using if_ = if_c; + //! @} + + /*! + * \name Named type selectors + */ + //! @{ + + //! Select the first type of a type sequence + template using first_of = T1; + + //! Select the second type of a type sequence + template using second_of = T2; + //! @} +}} + +//! @} + + + +/*! + * \ingroup basic + * \defgroup logic_operations Logic Operations + * logic operators and type relations support + */ +//! @{ +namespace utl { +namespace meta{ + + /*! + * \name Logical relation for types + */ + //! @{ + + //! Negate the *bool* constant parameter and return bool_ + template + using not_c = bool_; + + //! negate the bool_ parameter and return bool_ + template + using not_ = not_c; + + //! \name OR implementation + //! @{ + namespace details { + template struct _or_; + + template<> + struct _or_<> : false_ { }; + + template + struct _or_ : T1 { }; + + template + struct _or_ + : if_ { }; + + template + struct _or_ + : if_> { }; + } + + //! Operator or for bool_ types + //! \tparam Ts Variadic args of type bool_ + //! \return Logical or as bool_ + template + using or_ = eval>; + //! @} + + //! \name AND implementation + //! @{ + namespace details { + template struct _and_; + + template<> + struct _and_<> + : true_ { }; + + template + struct _and_ + : T1 { }; + + template + struct _and_ + : if_ { }; + + template + struct _and_ + : if_, T1> { }; + } + + //! Operator and for bool_ types + //! \tparam Ts Variadic args of type bool_ + //! \return Logical and as bool_ + template + using and_ = eval>; + //! @} + + //! \name same + //! @{ + template + struct same_ : false_ { }; + + template + struct same_ : true_ { }; + + template + using not_same_ = not_>>; + //! @} + + //! @} +}} + +//! @} + + +/*! + * \ingroup basic + * \defgroup integral_operators integral operators + * Type arithmetic and operations + */ +//! @{ + +namespace utl { +namespace meta { + + /*! + * \name Math operations + */ + //! @{ + + //! Negation + template + using negate = integral_; + //! Addition + template + using add = integral_< + decltype(Tp1() + Tp2()), + Tp1() + Tp2() + >; + //! Multiplication + template + using mult = integral_< + decltype(Tp2() * Tp2()), + Tp1() * Tp2() + >; + //! Division + template + using divide = integral_< + decltype(Tp2() / Tp2()), + Tp1() / Tp2() + >; + //! Modulo + template + using modulo = integral_< + decltype(Tp1() % Tp2()), + Tp1() % Tp2() + >; + //! Substruction + template + using sub = add>; + + //! Increase + template + using inc = add>; + + //! decrease + template + using dec = add>; + + //! @} + + /*! + * \name Comparison operations + */ + //! @{ + + //! \return a true-valued Integral Constant if Tp1 and Tp2 are equal. + template using comp_eq = bool_; + //! \return a true-valued Integral Constant if Tp1 is less than Tp2. + template using comp_lt = bool_<(Tp1() < Tp2())>; + + //! Not equal + template using comp_ne = not_>; + //! Greater than + template using comp_gt = comp_lt ; + //! Less or equal + template using comp_le = not_>; + //! Greater or equal + template using comp_ge = not_>; + //! @} + + /*! + * \name Bitwise operations + */ + //! @{ + + //! \return bitwise not (~) operation of its argument. + template using bitnot_ = integral_; + //! \return bitwise and (&) operation of its arguments + template + using bitand_ = integral_; + //! \return bitwise or (|) operation of its arguments. + template + using bitor_ = integral_; + + //! \return bitwise xor (^) operation of its arguments. + template + using bitxor_ = integral_; + //! \return the result of bitwise shift left (<<) operation on Tp. + template + using shift_left = integral_; + //! \return the result of bitwise shift right (>>) operation on Tp. + template + using shift_right = integral_> shift())>; + //! @} +}} +//! @} + +//! @} + #endif /* __utl_meta_basic_h__ */ diff --git a/include/utl/meta/detection.h b/include/utl/meta/detection.h index e9f653d..1d1964e 100644 --- a/include/utl/meta/detection.h +++ b/include/utl/meta/detection.h @@ -1,32 +1,17 @@ /*! * \file detection.h - * \brief Detection idiom based on WG21's \ref N4502 from Walter E. Brown - * - * \copyright - * Copyright (C) 2018 Christos Choutouridis \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 . - * - * \anchor N4502 www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4502.pdf + * \brief Detection idiom based on WG21's N4502 from Walter E. Brown */ #ifndef __utl_meta_detection_h__ #define __utl_meta_detection_h__ #include -#include +#include #include /*! * \ingroup meta - * \defgroup detection + * \defgroup detection Detection * Detection idiom support header. */ //! @{ @@ -45,7 +30,7 @@ namespace meta { }; //! void_t type alias template - using void_t = eval_t>; + using void_t = eval>; #else //! void_ meta-function that maps a sequence of any types to the type void template using void_ = void; @@ -138,7 +123,7 @@ namespace meta { * \endcode */ template class Op, typename... Args> - using detected_t = eval_t < + using detected_t = eval < details::detector >; @@ -164,7 +149,7 @@ namespace meta { */ template class Op, typename... Args> - using detected_or_t = eval_t < + using detected_or_t = eval < details::detected_or >; @@ -191,7 +176,7 @@ namespace meta { */ template class Op, typename... Args > - using is_detected_exact = eval_t < + using is_detected_exact = eval < same_> >; @@ -223,7 +208,7 @@ namespace meta { */ template class Op, typename... Args > - using is_detected_convertible = eval_t < + using is_detected_convertible = eval < std::is_convertible< detected_t, To > >; diff --git a/include/utl/meta/invoke.h b/include/utl/meta/invoke.h index 3465b0e..eeaea34 100644 --- a/include/utl/meta/invoke.h +++ b/include/utl/meta/invoke.h @@ -1,19 +1,6 @@ /*! * \file utl/meta/invoke.h * \brief Template meta-programming utilities for callables - * - * \copyright - * Copyright (C) 2018 Christos Choutouridis \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 . */ #ifndef __utl_meta_invoke_h__ #define __utl_meta_invoke_h__ @@ -21,17 +8,26 @@ #include #include #include -#include /*! * \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. + * \defgroup invoke Invoke + * A meta-programming invoke() analogous. + * + * This module provides higher order tools to meta. utl::meta's metafunctions inputs are types. + * The metafunctions though are templates in the form of `template class`. + * So we can not pass metafunctions to other metafunctions. The utl::meta provides tools to wrap metafunctions + * in a type. This way we create the concepts of: + * + * - \c invocable which is a type containing a metafunction inside. + * - \c evaluation which is the way of unwrapping the metafunction inside the invocable type. + * + * In order to accomplish that, by convention, a \c meta::invocable shall contain a nested + * template type named \c apply which is bind to actual invocable meta-function. Then we can: * - * - 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. + * - Use \c wrap<> or even better \c quote<> in order to wrap a metafunction to a type (metafunction class) + * - Pass these wrapped types to other metafunctions + * - \c invoke<> the inner \c apply from a wrapped metafunction class. */ //! @{ namespace utl { diff --git a/include/utl/meta/meta.h b/include/utl/meta/meta.h index d74f3b9..c4162e6 100644 --- a/include/utl/meta/meta.h +++ b/include/utl/meta/meta.h @@ -1,32 +1,39 @@ /*! * \file utl/meta/meta.h * \brief Meta library forward header - * - * \copyright - * Copyright (C) 2018 Christos Choutouridis \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 . - * */ #ifndef __utl_meta_meta_h__ #define __utl_meta_meta_h__ -//! \defgroup meta Meta -//! An embedded metaprogramming library for uTL. -//! +/*! \defgroup meta Meta + * An embedded metaprogramming library for uTL. + * + * uTL::meta is a simple metaprogramming library used widely inside uTL. + * The lib is provided to the end user via namespace \c utl::meta + * The library consist of: + * + * - integral constant based, operation and arithmetic functionality\n + * meta defines wrappers for all of integral types such as \c int, \c long, \c char, \c uint32_t etc... + * and also facilities to emulate: + * 1. conditional (if) + * 2. logical operations like \c or, \c and, \c not, \c bitor, \c bitand etc... + * 3. math operations like \c add, \c sub, \c modulo + * 4. comparison operations like \c equal, \c not_equal etc... + * All of these operate on integral types. + * - SFINAE wrappers as syntactic sugar to the rest of the uTL. + * - Walter's Brown detection idiom to help uTL concept implementation. + * - Higher order metafunction tools for composition.\n + * This module provides tools such as \c wrap, \c compose, \c fold, \c bind etc... The user can + * wrap metafunctions as types and pass them around other metafunctions. The evaluation + * of these functions can be done both aggressive or lazy using tools such as \c eval or \c invoke + * - typelist "container" implementation.\n + * Typelist is a container like template type holding the parameter list as items in the container. + * This facility has also all the expected eco-system of functions like \c push_front, + * \c push_back, \c at etc... + */ #include -#include -#include -#include +#include #include #include #include diff --git a/include/utl/meta/operations.h b/include/utl/meta/operations.h deleted file mode 100644 index 1ff1a8d..0000000 --- a/include/utl/meta/operations.h +++ /dev/null @@ -1,225 +0,0 @@ -/*! - * \file operations.h - * \brief Integral constant operations and logical operations - * - * \copyright - * Copyright (C) 2018 Christos Choutouridis \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 . - */ -#ifndef __utl_meta_operations_h__ -#define __utl_meta_operations_h__ - -#include -#include - - -/*! - * \ingroup meta - * \defgroup logic_operations Logic Operations - * logic operators and type relations support - */ -//! @{ -namespace utl { -namespace meta{ - - /*! - * \name Logical relation for types - */ - //! @{ - - //! Negate the *bool* constant parameter and return bool_ - template - using not_c = bool_; - - //! negate the bool_ parameter and return bool_ - template - using not_ = not_c; - - //! \name OR implementation - //! @{ - namespace details { - template struct _or_; - - template<> - struct _or_<> : false_ { }; - - template - struct _or_ : T1 { }; - - template - struct _or_ - : if_ { }; - - template - struct _or_ - : if_> { }; - } - - //! Operator or for bool_ types - //! \tparam Ts Variadic args of type bool_ - //! \return Logical or as bool_ - template - using or_ = eval_t>; - //! @} - - //! \name AND implementation - //! @{ - namespace details { - template struct _and_; - - template<> - struct _and_<> - : true_ { }; - - template - struct _and_ - : T1 { }; - - template - struct _and_ - : if_ { }; - - template - struct _and_ - : if_, T1> { }; - } - - //! Operator and for bool_ types - //! \tparam Ts Variadic args of type bool_ - //! \return Logical and as bool_ - template - using and_ = eval_t>; - //! @} - - //! \name same - //! @{ - template - struct same_ : false_ { }; - - template - struct same_ : true_ { }; - - template - using not_same_ = not_>>; - //! @} - - //! @} -}} - -//! @} - - -/*! - * \ingroup meta - * \defgroup integral_operators integral operators - * Type arithmetic and operations - */ -//! @{ - -namespace utl { -namespace meta { - - /*! - * \name Math operations - */ - //! @{ - - //! Negation - template - using negate = integral_; - //! Addition - template - using add = integral_< - decltype(Tp1() + Tp2()), - Tp1() + Tp2() - >; - //! Multiplication - template - using mult = integral_< - decltype(Tp2() * Tp2()), - Tp1() * Tp2() - >; - //! Division - template - using divide = integral_< - decltype(Tp2() / Tp2()), - Tp1() / Tp2() - >; - //! Modulo - template - using modulo = integral_< - decltype(Tp1() % Tp2()), - Tp1() % Tp2() - >; - //! Substruction - template - using sub = add>; - - //! Increase - template - using inc = add>; - - //! decrease - template - using dec = add>; - - //! @} - - /*! - * \name Comparison operations - */ - //! @{ - - //! \return a true-valued Integral Constant if Tp1 and Tp2 are equal. - template using comp_eq = bool_; - //! \return a true-valued Integral Constant if Tp1 is less than Tp2. - template using comp_lt = bool_<(Tp1() < Tp2())>; - - //! Not equal - template using comp_ne = not_>; - //! Greater than - template using comp_gt = comp_lt ; - //! Less or equal - template using comp_le = not_>; - //! Greater or equal - template using comp_ge = not_>; - //! @} - - /*! - * \name Bitwise operations - */ - //! @{ - - //! \return bitwise not (~) operation of its argument. - template using bitnot_ = integral_; - //! \return bitwise and (&) operation of its arguments - template - using bitand_ = integral_; - //! \return bitwise or (|) operation of its arguments. - template - using bitor_ = integral_; - - //! \return bitwise xor (^) operation of its arguments. - template - using bitxor_ = integral_; - //! \return the result of bitwise shift left (<<) operation on Tp. - template - using shift_left = integral_; - //! \return the result of bitwise shift right (>>) operation on Tp. - template - using shift_right = integral_> shift())>; - //! @} -}} -//!@} - - -#endif /* __utl_meta_operations_h__ */ diff --git a/include/utl/meta/selection.h b/include/utl/meta/selection.h deleted file mode 100644 index f6cde0f..0000000 --- a/include/utl/meta/selection.h +++ /dev/null @@ -1,79 +0,0 @@ -/*! - * \file selection.h - * \brief Template meta-programming type selections. - * - * \copyright - * Copyright (C) 2018 Christos Choutouridis \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 . - */ -#ifndef __utl_meta_selection_h__ -#define __utl_meta_selection_h__ - -#include -#include - -/*! - * \ingroup meta - * \defgroup selection Selection - * Type selection support header - */ -//! @{ -namespace utl { -namespace meta{ - - //! \name if implementation - //! @{ - namespace details { - 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 = eval_t>; - - //! Select one type or another depending on a compile-time Boolean type - template - using if_ = if_c; - - //! @} - - /*! - * \name Named type selectors - */ - //! @{ - - //! Select the first type of a type sequence - template using first_of = T1; - - //! Select the second type of a type sequence - template using second_of = T2; - - //! @} -}} - -//! @} - -#endif /* __utl_meta_selection_h__ */ diff --git a/include/utl/meta/sfinae.h b/include/utl/meta/sfinae.h index d1db6d9..a672963 100644 --- a/include/utl/meta/sfinae.h +++ b/include/utl/meta/sfinae.h @@ -1,19 +1,6 @@ /*! * \file sfinae.h * \brief Template meta-programming SFINAE helpers - * - * \copyright - * Copyright (C) 2018 Christos Choutouridis \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 . */ #ifndef __utl_meta_sfinae_h__ #define __utl_meta_sfinae_h__ @@ -23,13 +10,24 @@ /*! * \ingroup meta - * \defgroup sfinae sfinae + * \defgroup sfinae SFINAE * conditional use support header. */ //! @{ namespace utl { namespace meta { + //! \name enable_if from STL + //! @{ + + //! enable_if, imported from stl + template using enable_if = std::enable_if; + + //! alias template for enable_if + template using enable_if_t = eval< enable_if >; + + //! @} + //! \name when implementation //! @{ namespace details { @@ -42,7 +40,7 @@ namespace meta { //! Tool to enable a partial specialization only if a boolean condition is true. //! Well formed only if \p If is true template - using when = eval_t< details::when_ >; + using when = eval< details::when_ >; // //! Well formed only if all of \p Ifs are \c true // template @@ -52,16 +50,29 @@ namespace meta { //! @} - //! \name enable_if from STL - //! @{ + //! If same type resolves to _Ret, else SFINAE + template + using use_if_same_t = enable_if_t< + same_<_T1, _T2>::value, _Ret + >; + //! If not same type resolves to _Ret, else SFINAE + template + using use_if_not_same_t = enable_if_t< + !same_<_T1, _T2>::value, _Ret + >; + //! If any type (_T1 or _T2) type resolves to _Ret, else to SFINAE + template + using use_if_any_t = enable_if_t< + or_::value, T1 + >; - //! enable_if, imported from stl - template using enable_if = std::enable_if; + //! If both type (_T1 and _T2) type resolves to _Ret, else to SFINAE + template + using use_if_all_t = enable_if_t< + and_::value, T1 + >; - //! alias template for enable_if - template using enable_if_t = eval_t< enable_if >; - //! @} }} diff --git a/include/utl/meta/typelist.h b/include/utl/meta/typelist.h index 07b33d5..2b7acbf 100644 --- a/include/utl/meta/typelist.h +++ b/include/utl/meta/typelist.h @@ -32,7 +32,7 @@ namespace meta { * (even if the parameter typelist contains void or some type that lacks * a default constructor).\n * - * \code + * \code{.cpp} * using l1 = typelist; * l1 a {}; * \endcode @@ -89,7 +89,7 @@ namespace meta { /*! * Generate typelist of size \c N arguments. * - * \code + * \code{.cpp} * static_assert ( * std::is_same::times<2>, * typelist @@ -108,8 +108,8 @@ namespace meta { * * Complexity \f$ O(1) \f$. * - * \param List A typelist - * \return The size of the typelist + * \tparam List A typelist + * \return The size of the typelist */ template using size = size_; @@ -119,8 +119,8 @@ namespace meta { * * Complexity \f$ O(1) \f$. * - * \param List A typelist - * \return Empty or not + * \tparam List A typelist + * \return Empty or not */ template using empty = bool_; @@ -131,24 +131,24 @@ namespace meta { using pair = typelist; - //! repeat + //! \name repeat //! @{ /*! - * A wrapper to typelist<>::times<> utility for integer argument \p N + * A wrapper to typelist<>::times<> utility for integer argument \c N */ template using repeat_c = typename typelist::template times; /*! - * A wrapper to typelist<>::times<> utility for integral_c argument \p N + * A wrapper to typelist<>::times<> utility for integral_c argument \c N */ template using repeat = repeat_c; //! @} /*! - * Apply + * \name Apply * An analogous to apply() implementation for tuples. We just use * Our typelist<> and integer_sequence<> types. */ @@ -157,7 +157,7 @@ namespace meta { template struct apply_ { }; - //! \p Sequence == typelist<> + //! \c Sequence == typelist<> template struct apply_> { using type = invoke; @@ -170,13 +170,13 @@ namespace meta { } /*! - * Apply the Invocable \p Fn using the types in the type \p Seq as arguments. + * Apply the Invocable \c Fn using the types in the type \c Seq as arguments. * \note * This is the opposed operation of typelist * - * If \p Seq == typelist<> then + * If \c Seq == typelist<> then * Unpack typelist and apply to \c Fn - * It \p Seq == integer_sequence<> then + * It \c Seq == integer_sequence<> then * Unpack and use the integral_c<> of each integer */ template @@ -190,9 +190,9 @@ namespace meta { /* * ========= element access ======== */ - //! at: random element access + //! \name random element access //! @{ - namespace details { + namespace at_impl { template struct _add_pointer { using type = T*; }; template using add_pointer = eval < _add_pointer >; @@ -221,26 +221,26 @@ namespace meta { } /*! - * Return the \p N th element in the \c meta::typelist \p List. + * Return the \c N th element in the \c meta::typelist \c List. * * Complexity \f$ O(logN) \f$. */ template using at_c = eval< - details::at_ + at_impl::at_ >; /*! - * Return the \p N th element in the \c meta::typelist \p List. + * Return the \c N th element in the \c meta::typelist \c List. * - * Complexity \f$ O(N) \f$. + * Complexity \f$ O(logN) \f$. */ template using at = at_c; //!@} - //! front + //! \name front //! @{ namespace front_impl { template @@ -252,7 +252,8 @@ namespace meta { }; } - //! Return the first element in \c meta::typelist \p List. + //! Return the first element in \c meta::typelist \c List. + //! //! Complexity \f$ O(1) \f$. template using front = eval< @@ -260,7 +261,7 @@ namespace meta { >; //! @} - //! back + //! \name back //! @{ namespace back_impl { template @@ -274,7 +275,8 @@ namespace meta { }; } - //! Return the last element in \c meta::typelist \p List. + //! Return the last element in \c meta::typelist \c List. + //! //! Complexity \f$ O(N) \f$. template using back = eval< @@ -285,7 +287,7 @@ namespace meta { * ========= typelist operations ========= */ - //! Concatenation + //! \name Concatenation //! @{ namespace cat_impl { template @@ -315,8 +317,9 @@ namespace meta { /*! * Transformation that concatenates several lists into a single typelist. * The parameters must all be instantiations of \c meta::typelist. + * * Complexity: \f$ O(N) \f$ - * where \f$ N \f$ is the number of lists passed to the algorithm. + * where \f$ N \f$ is the number of lists passed to the algorithm. */ template using cat = eval< @@ -325,7 +328,7 @@ namespace meta { //! @} - //! fold, rev_fold + //! \name Fold //! @{ namespace fold_impl { // fold<, V, F> == F, T2>, T3> @@ -354,16 +357,17 @@ namespace meta { } /*! - * transform the \p List to a new one by doing a left fold using binary Invocable \p Fn - * and initial value \p V + * transform the \c List to a new one by doing a left fold using binary Invocable \c Fn + * and initial value \c V + * * Complexity \f$ O(N) \f$ - * \example + * \code{.cpp} * fold, V, F> == F, T2>, T3> - * \example * fold, V, F> == V - * \param List The list to fold - * \param V The initial item feeded to Fn - * \param Fn The binary Invocable + * \endcode + * \tparam List The list to fold + * \tparam V The initial item feeded to Fn + * \tparam Fn The binary Invocable */ template using fold = eval>; @@ -407,16 +411,17 @@ namespace meta { } /*! - * transform the \p List to a new one by doing a right fold using binary Invocable \p Fn - * and initial value \p V + * transform the \c List to a new one by doing a right fold using binary Invocable \c Fn + * and initial value \c V + * * Complexity \f$ O(N) \f$ - * \example + * \code{.cpp} * rev_fold, V, F> == F>> - * \example * rev_fold, V, F> == V - * \param List The list to fold - * \param V The initial item fed to Fn - * \param Fn The binary Invocable + * \endcode + * \tparam List The list to fold + * \tparam V The initial item fed to Fn + * \tparam Fn The binary Invocable */ template using rev_fold = eval< @@ -425,7 +430,8 @@ namespace meta { //! @} /*! - * Return a new \c typelist by adding the elements \p Ts to the front of \p List. + * Return a new \c typelist by adding the elements \c Ts to the front of \c List. + * * Complexity \f$ O(1) \f$ */ template @@ -436,7 +442,8 @@ namespace meta { >; /*! - * Return a new \c typelist by adding the elements \p Ts to the back of \p List. + * Return a new \c typelist by adding the elements \c Ts to the back of \c List. + * * Complexity \f$ O(1) \f$ */ template @@ -446,7 +453,7 @@ namespace meta { > >; - //! reverse + //! \name reverse //! @{ namespace reverse_impl { template > @@ -456,7 +463,8 @@ namespace meta { } /*! - * Return a new \c typelist by reversing the elements in the list \p List. + * Return a new \c typelist by reversing the elements in the list \c List. + * * Complexity \f$ O(N) \f$ */ template @@ -465,7 +473,7 @@ namespace meta { >; //! @} - //! pop_front + //! \name pop_front //! @{ namespace pop_front_impl { template @@ -479,7 +487,8 @@ namespace meta { /*! * Return a new \c typelist by removing the first element from the - * front of \p List. + * front of \c List. + * * Complexity \f$ O(1) \f$ */ template @@ -488,7 +497,7 @@ namespace meta { >; //! @} - //! pop_back + //! \name pop_back //! @{ namespace pop_back_impl { template @@ -500,7 +509,8 @@ namespace meta { } /*! - * Return a new \c typelist by removing the last element from the \p List. + * Return a new \c typelist by removing the last element from the \c List. + * * Complexity \f$ O(N) \f$. * \note * This operation, in addition from other push/pop operations, is @@ -512,7 +522,7 @@ namespace meta { >; //! @} - //! Transform + //! \name Transform //! @{ namespace transform_impl { template @@ -540,8 +550,7 @@ namespace meta { * and return the resulting typelist * * Complexity \f$ O(N) \f$. - * \example - * \code + * \code{.cpp} * using l1 = typelist; * using l2 = typelist; * using r1 = transform; // F1, unary invocable @@ -554,7 +563,7 @@ namespace meta { >; //! @} - //! Transform lazy + //! \name Transform lazy //! @{ namespace transform_lazy_impl { template @@ -586,8 +595,7 @@ namespace meta { * * Complexity \f$ O(N) \f$ * - * \example - * \code + * \code{.cpp} * using l1 = typelist; * using l2 = typelist; * using r1 = transform; // F1, unary invocable @@ -601,7 +609,7 @@ namespace meta { //! @} - //! find_if, find + //! \name find_if, find //! @{ namespace find_if_impl { template @@ -627,13 +635,13 @@ namespace meta { } /*! - * Search for the first \c Item on the \p List for which the predicate \p Pred + * Search for the first \c Item on the \c List for which the predicate \c Pred * returns true_ when `eval>` * * Complexity \f$ O(N) \f$ * - * \param List A typelist - * \param Pred A Unary invocable predicate + * \tparam List A typelist + * \tparam Pred A Unary invocable predicate * \return An integral constant of index_t with the location of the first match, * or Npos otherwise. */ @@ -643,13 +651,13 @@ namespace meta { >; /*! - * Search for the first occurrence of type \p T on a \p List + * Search for the first occurrence of type \c T on a \c List */ template using find = find_if>; //! @} - //! seek_if + //! \name seek_if //! @{ namespace seek_if_impl { template @@ -675,14 +683,14 @@ namespace meta { } /*! - * Search for the first \c Item on the \p List for which the predicate \p Pred - * returns true_ when `eval>` and return the rest of the \p List + * Search for the first \c Item on the \c List for which the predicate \c Pred + * returns true_ when `eval>` and return the rest of the \c List * starting from that position as new typelist * * Complexity \f$ O(N) \f$ * - * \param List A typelist - * \param Pred A Unary invocable predicate + * \tparam List A typelist + * \tparam Pred A Unary invocable predicate * \return An integral constant with the location of the first match, on Npos otherwise */ template @@ -690,14 +698,14 @@ namespace meta { seek_if_impl::seek_if_ >; /*! - * Search for the first \c Item on the \p List of type \p T and return the rest - * of the \p List starting from that position as new typelist + * Search for the first \c Item on the \c List of type \c T and return the rest + * of the \c List starting from that position as new typelist */ template using seek = seek_if >; //! @} - //! count_if + //! \name count_if //! @{ namespace count_if_impl { template @@ -726,13 +734,13 @@ namespace meta { } /*! - * Count all \c Items on the \p List for which the predicate \p Pred + * Count all \c Items on the \c List for which the predicate \c Pred * returns true_ when `eval>` * * Complexity \f$ O(N) \f$ * - * \param List A typelist - * \param Pred A Unary invocable predicate + * \tparam List A typelist + * \tparam Pred A Unary invocable predicate * \return The total count of occurrences as an integral constant of size_t */ template @@ -741,13 +749,13 @@ namespace meta { >; /*! - * Count all occurrences of type \p T int \p List + * Count all occurrences of type \c T int \c List */ template using count = count_if>; //! @} - //! filter + //! \name filter //! @{ namespace filter_impl { template @@ -772,13 +780,13 @@ namespace meta { } /*! - * Return a new typelist with elements, the elements of \p List that satisfy the - * invocable \p Pred such that `eval>` is \c true_ + * Return a new typelist with elements, the elements of \c List that satisfy the + * invocable \c Pred such that `eval>` is \c true_ * * Complexity \f$ O(N) \f$ * - * \param List The input typelist - * \param Pred A unary invocable predicate + * \tparam List The input typelist + * \tparam Pred A unary invocable predicate */ template using filter = eval< @@ -786,7 +794,7 @@ namespace meta { >; //! @} - //! replace + //! \name replace //! @{ namespace replace_if_impl { template @@ -811,14 +819,14 @@ namespace meta { } /*! - * Return a new typelist where all the instances for which the invocation of\p Pred - * returns \c true_, are replaced with \p T + * Return a new typelist where all the instances for which the invocation of\c Pred + * returns \c true_, are replaced with \c T * * Complexity \f$ O(N) \f$ * - * \param List The input typelist - * \param Pred A unary invocable predicate - * \param T The new type to replace the item of the \p List, when eval> + * \tparam List The input typelist + * \tparam Pred A unary invocable predicate + * \tparam T The new type to replace the item of the \c List, when eval> * returns \c true_ */ template @@ -826,8 +834,8 @@ namespace meta { replace_if_impl::replace_if_> >; - //! Alias wrapper that returns a new \c typelist where all instances of type \p T have - //! been replaced with \p U. + //! Alias wrapper that returns a new \c typelist where all instances of type \c T have + //! been replaced with \c U. template using replace = eval < replace_if , U> @@ -835,8 +843,8 @@ namespace meta { //! @} - //! Returns \c true_ if \p Pred returns \c true_ for all the elements in the \p List or if the - //! \p List is empty and \c false_ otherwise. + //! Returns \c true_ if \c Pred returns \c true_ for all the elements in the \c List or if the + //! \c List is empty and \c false_ otherwise. template using all_of = if_ < empty , @@ -846,15 +854,15 @@ namespace meta { > >; - //! Returns \c true_ if \p Pred returns \c true_ for any of the elements in the \p List + //! Returns \c true_ if \c Pred returns \c true_ for any of the elements in the \c List //! and \c false_ otherwise. template using any_of = not_< empty> >; - //! Returns \c true_ if \p Pred returns \c false_ for all the elements in the \p List - //! or if the \p List is empty and \c false otherwise. + //! Returns \c true_ if \c Pred returns \c false_ for all the elements in the \c List + //! or if the \c List is empty and \c false otherwise. template using none_of = empty< filter diff --git a/include/utl/meta/useif.h b/include/utl/meta/useif.h deleted file mode 100644 index b676d33..0000000 --- a/include/utl/meta/useif.h +++ /dev/null @@ -1,60 +0,0 @@ -/*! - * \file useif.h - * \brief Template meta-programming SFINAE helpers - * - * \copyright - * Copyright (C) 2018 Christos Choutouridis \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 . - * - */ -#ifndef __utl_meta_useif_h__ -#define __utl_meta_useif_h__ - -#include -#include -#include - -/*! - * \ingroup meta - * \addtogroup sfinae - */ -//! @{ -namespace utl { -namespace meta { - - //! If same type resolves to Ret, else SFINAE - template - using use_if_same_t = enable_if_t< - eval_v>, Ret - >; - //! If not same type resolves to Ret, else SFINAE - template - using use_if_not_same_t = enable_if_t< - eval_v>, Ret - >; - //! If any type (T1 or T2) type resolves to Ret, else to SFINAE - template - using use_if_any_t = enable_if_t< - eval_v>, T1 - >; - - //! If both type (T1 and T2) type resolves to Ret, else to SFINAE - template - using use_if_all_t = enable_if_t< - eval_v>, T1 - >; - -}} - -//! @} - -#endif /* __utl_meta_useif_h__ */ diff --git a/include/utl/utility/invoke.h b/include/utl/utility/invoke.h index 32717d0..270fa51 100644 --- a/include/utl/utility/invoke.h +++ b/include/utl/utility/invoke.h @@ -1,21 +1,6 @@ /*! * \file utl/utility/invoke.h * \brief invoke() and invoke traits implementation - * - * 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 detail. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . */ #ifndef __utl_utility_invoke_h__ #define __utl_utility_invoke_h__ @@ -29,7 +14,7 @@ /*! * \ingroup utility - * \defgroup invoke + * \defgroup invoke Invoke */ //! @{ namespace utl { @@ -125,7 +110,7 @@ namespace utl { } //! @} - //! std::is_invocable trait for C++11 + //! std::is_invocable trait for C++14 template struct is_invocable : std::is_constructible< @@ -133,7 +118,7 @@ namespace utl { std::reference_wrapper::type> > { }; - //! std::is_invocable_r trait for C++11 + //! std::is_invocable_r trait for C++14 template struct is_invocable_r : std::is_constructible<