diff --git a/include/utl/com/_1wire.h b/include/utl/com/_1wire.h index 55cb026..d7e47f0 100644 --- a/include/utl/com/_1wire.h +++ b/include/utl/com/_1wire.h @@ -709,8 +709,8 @@ namespace _1wire_i_det { * \param _Tp Type to check * \return True if _Tp is a 1-wire interface */ - template - constexpr bool _1Wire_i = _1wire_i_det::is_1wire_<_Tp>::value; +// template +// constexpr bool _1Wire_i = _1wire_i_det::is_1wire_<_Tp>::value; #endif //!@} diff --git a/include/utl/com/_1wire_id.h b/include/utl/com/_1wire_id.h index e655246..3dd1845 100644 --- a/include/utl/com/_1wire_id.h +++ b/include/utl/com/_1wire_id.h @@ -70,7 +70,7 @@ namespace utl { * \arg 1 dev_id rhs is smaller than dev_id lhs */ static int compare (const _1wire_id_t& lhs, const _1wire_id_t& rhs) noexcept { - auto p = std::mismatch (lhs.rbegin(), lhs.rend(), rhs.rbegin(), rhs.rend()); + auto p = std::mismatch (lhs.rbegin(), lhs.rend(), rhs.rbegin()); if (p.first == lhs.rend()) return 0; else if (*p.first < *p.second) return -1; else return 1; diff --git a/include/utl/com/i2c.h b/include/utl/com/i2c.h index 3d6b35e..948f5ba 100644 --- a/include/utl/com/i2c.h +++ b/include/utl/com/i2c.h @@ -275,8 +275,8 @@ namespace utl { * \param _Tp Type to check * \return True if _Tp is a i2c interface */ - template - constexpr bool I2c_i = i2c_i_details::is_i2c_<_Tp>::value; +// template +// constexpr bool I2c_i = i2c_i_details::is_i2c_<_Tp>::value; #endif //!@} diff --git a/include/utl/com/spi.h b/include/utl/com/spi.h index 72dfc04..5516edd 100644 --- a/include/utl/com/spi.h +++ b/include/utl/com/spi.h @@ -321,8 +321,8 @@ namespace utl { * \param _Tp Type to check * \return True if _Tp is a spi interface */ - template - constexpr bool Spi_i = spi_i_details::is_spi_<_Tp>::value; +// template +// constexpr bool Spi_i = spi_i_details::is_spi_<_Tp>::value; #endif //! @} diff --git a/include/utl/container/id.h b/include/utl/container/id.h index 2496425..61fa148 100644 --- a/include/utl/container/id.h +++ b/include/utl/container/id.h @@ -157,9 +157,8 @@ namespace utl { * \param bit The bit location we want to read */ constexpr bool bit (uint8_t bit) const noexcept { - value_type one = 1; - uint8_t den = 8*sizeof(_Tp)/sizeof(uint8_t); - return traits_t::Ref (_data, bit/den) & (one << ((bit % den)-1)); + return traits_t::Ref (_data, bit/(8*sizeof(_Tp))) & + (static_cast(0x01) << ((bit % (8*sizeof(_Tp)))-1)); } /*! diff --git a/include/utl/core/concepts/concepts.h b/include/utl/core/concepts/concepts.h deleted file mode 100755 index 5e38655..0000000 --- a/include/utl/core/concepts/concepts.h +++ /dev/null @@ -1,44 +0,0 @@ -/*! - * \file /utl/impl/concepts.h - * \brief Concept 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 . - * - */ -#ifndef __utl_impl_concepts_h__ -#define __utl_impl_concepts_h__ - -/*! - * utl inner concept preprocessor flag - * \defgroup crtp - * \ingroup impl - */ -//!@{ -#if defined __cpp_concepts -#define _utl_have_concepts (1) -#endif - -/*! - * requires keyword wrapper - */ -#if defined _utl_have_concepts - #define _requires(_r_) requires (_r_) -#else - #define _requires(_r_) -#endif - -//!@} -#endif /* __utl_impl_concepts_h__ */ diff --git a/include/utl/core/crtp.h b/include/utl/core/crtp.h index e67cfad..fff7b67 100644 --- a/include/utl/core/crtp.h +++ b/include/utl/core/crtp.h @@ -43,6 +43,7 @@ namespace utl { #define _CRTP_IMPL(T) \ constexpr T& impl() { return *static_cast(this); } \ constexpr const T& impl() const { return *static_cast(this); } + } //!@} #endif /* __utl_impl_crtp_h__ */ diff --git a/include/utl/core/types.h b/include/utl/core/types.h index 909fc90..4bce78f 100644 --- a/include/utl/core/types.h +++ b/include/utl/core/types.h @@ -24,6 +24,8 @@ #include #include +//#include + namespace utl { //! @{ \name byte and word types using byte_t = uint8_t; //!< 8 bits wide diff --git a/include/utl/core/version.h b/include/utl/core/version.h index cdfc488..8df226e 100755 --- a/include/utl/core/version.h +++ b/include/utl/core/version.h @@ -2,7 +2,7 @@ * \file /utl/core/version.h * \brief version and cpp version checks * - * Copyright (C) 2018 Christos Choutouridis + * 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 @@ -26,10 +26,10 @@ //!@{ //! utl version -#define UTL_VERSION "0.0.1" +#define UTL_VERSION "0.1.0" #define UTL_VERSION_MAJOR 0 -#define UTL_VERSION_MINOR 0 -#define UTL_VERSION_PATCH 1 +#define UTL_VERSION_MINOR 1 +#define UTL_VERSION_PATCH 0 #define UTL_VERSION_VALUE ( (UTL_VERSION_MAJOR * 10000) \ + (UTL_VERSION_MINOR * 100) \ + UTL_VERSION_PATCH) @@ -40,8 +40,6 @@ #define CXX_VER_STD_14 201402L #define CXX_VER_STD_17 201703L -//#include - //! Check for variable templates #ifndef CXX_VARIABLE_TEMPLATES #ifdef __cpp_variable_templates @@ -51,15 +49,6 @@ #endif #endif -//! Check integer sequence -#ifndef CXX_INTEGER_SEQUENCE - #ifdef __cpp_lib_integer_sequence - #define CXX_INTEGER_SEQUENCE __cpp_lib_integer_sequence - #else - #define CXX_INTEGER_SEQUENCE (CXX_VER >= CXX_VER_STD_14) - #endif -#endif - //! Check concepts #ifndef CXX_CONCEPTS #ifdef __cpp_concepts @@ -86,9 +75,8 @@ #endif #endif - /* - * Workaround inspection + * Workaround inspections */ #if defined(__GNUC__) && (__GNUC__ < 5) // https://wg21.link/cwg1558 @@ -97,8 +85,8 @@ //! Base library requirement -#if __cplusplus < CXX_VER_STD_11 -#error "uTL requires C++11" +#if CXX_VER < CXX_VER_STD_14 +#error "uTL requires C++14" #endif //!@} diff --git a/include/utl/dev/dev_iterators.h b/include/utl/dev/dev_iterators.h index 51e682a..32aafb7 100644 --- a/include/utl/dev/dev_iterators.h +++ b/include/utl/dev/dev_iterators.h @@ -437,8 +437,8 @@ namespace utl { * \param _Tp Type to check * \return True if _Tp is a spi interface */ - template - constexpr bool Outdev_it = outdev_it_details::is_outdev_it_<_Tp>::value; +// template +// constexpr bool Outdev_it = outdev_it_details::is_outdev_it_<_Tp>::value; #endif //! @} @@ -714,8 +714,8 @@ namespace utl { * \param _Tp Type to check * \return True if _Tp is a spi interface */ - template - constexpr bool Indev_it = indev_it_details::is_indev_it_<_Tp>::value; +// template +// constexpr bool Indev_it = indev_it_details::is_indev_it_<_Tp>::value; #endif //! @} @@ -998,8 +998,8 @@ namespace utl { * \param _Tp Type to check * \return True if _Tp is a spi interface */ - template - constexpr bool Idxdev_it = idxdev_it_details::is_idxdev_it_<_Tp>::value; +// template +// constexpr bool Idxdev_it = idxdev_it_details::is_idxdev_it_<_Tp>::value; #endif //! @} diff --git a/include/utl/meta/void.h b/include/utl/meta/detection.h similarity index 72% rename from include/utl/meta/void.h rename to include/utl/meta/detection.h index d40b20c..0ee292c 100644 --- a/include/utl/meta/void.h +++ b/include/utl/meta/detection.h @@ -1,8 +1,10 @@ /*! - * \file void.h - * \brief void_t meta-function + * \file detection.h + * \brief Detection idiom based on WG21's N4502[1] from Walter E. Brown * - * Copyright (C) 2018 Christos Choutouridis + * [1]: www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4502.pdf + * + * 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 @@ -17,14 +19,17 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ -#ifndef __utl_meta_void_h__ -#define __utl_meta_void_h__ +#ifndef __utl_meta_detection_h__ +#define __utl_meta_detection_h__ #include +#include +#include /*! * \ingroup meta - * \defgroup void + * \defgroup detection + * Detection idiom support header. */ //! @{ @@ -42,7 +47,7 @@ namespace meta { }; //! void_t type alias template - using void_t = type_of>; + using void_t = eval>; #else //! void_ type alias template using void_ = void; diff --git a/include/utl/meta/idx_sequence.h b/include/utl/meta/idx_sequence.h index 19b1dcc..12bf3ba 100644 --- a/include/utl/meta/idx_sequence.h +++ b/include/utl/meta/idx_sequence.h @@ -2,7 +2,7 @@ * \file pack.h * \brief Template meta-programming parameter pack container * - * Copyright (C) 2018 Christos Choutouridis + * 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 @@ -65,8 +65,8 @@ namespace meta { // Builds an index_tuple<0, 1, 2, ..., _Num-1>. template struct make_index_tuple_ - : it_cat_>, - type_>> + : it_cat_>, + eval>> { }; // termination specialization for 1 template<> @@ -81,7 +81,7 @@ namespace meta { // factory type template>> + typename _ISeq = eval>> struct make_integer_sequence_; template @@ -94,7 +94,7 @@ namespace meta { //! Alias template make_integer_sequence //! Complexity \f$ O(log N) \f$ template - using make_integer_sequence = type_>; + using make_integer_sequence = eval>; //! Alias template make_index_sequence //! Complexity \f$ O(log N) \f$ diff --git a/include/utl/meta/integral.h b/include/utl/meta/integral.h index e81f8a6..1301074 100644 --- a/include/utl/meta/integral.h +++ b/include/utl/meta/integral.h @@ -2,7 +2,7 @@ * \file integralconstant.h * \brief Template meta-programming integral constant * - * Copyright (C) 2018 Christos Choutouridis + * 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 @@ -43,20 +43,20 @@ namespace meta { using type = nil_; }; - //! Type alias for \p _Tp::type. Used to extract return type of metafunctions + //! Type alias for \p _Tp::type. Used to evaluate/extract return type of metafunctions template - using type_ = typename _Tp::type; + using eval = typename _Tp::type; - //! integral_constant - //! An Integral Constant is a holder class for a compile-time value of an integral type. + //! integral_ + //! Integral Constant is a holder class for a compile-time value of an integral type. //! Every Integral Constant is also a null-ary Metafunction, returning itself. //! An integral constant object is implicitly convertible to the corresponding //! run-time value of the wrapped integral type //! @{ template - struct integral_constant { + struct integral_ { using value_type = _Tp; - using type = integral_constant<_Tp, _v>; + using type = integral_<_Tp, _v>; constexpr operator value_type() const noexcept { return value; @@ -68,77 +68,73 @@ namespace meta { }; template - constexpr _Tp integral_constant<_Tp, _v>::value; + constexpr _Tp integral_<_Tp, _v>::value; //! @} //! Wrappers for basic types //! @{ - //! integral constant - template - using integral_c = integral_constant<_Tp, _v>; - //! bool_ type: integral constant wrapper for bool template - using bool_ = integral_c; + using bool_ = integral_; using true_ = bool_; //!< The type used as a compile-time boolean with true value. using false_ = bool_; //!< The type used as a compile-time boolean with false value. //! int8_ type: integral constant wrapper for \c int8_t template - using int8_ = integral_c; + using int8_ = integral_; //! uint8_ type: integral constant wrapper for \c uint8_t template - using uint8_ = integral_c; + using uint8_ = integral_; //! int16_ type: integral constant wrapper for \c int16_t template - using int16_ = integral_c; + using int16_ = integral_; //! uint16_ type: integral constant wrapper for \c uint16_t template - using uint16_ = integral_c; + using uint16_ = integral_; //! int32_ type: integral constant wrapper for \c int32_t template - using int32_ = integral_c; + using int32_ = integral_; //! uint32_ type: integral constant wrapper for \c uint32_t template - using uint32_ = integral_c; + using uint32_ = integral_; //! char_ type: integral constant wrapper for \c char template - using char_ = integral_c; + using char_ = integral_; //! int_ type: integral constant wrapper for \c int template - using int_ = integral_c; + using int_ = integral_; //! long_ type: integral constant wrapper for \c long template - using long_ = integral_c; + using long_ = integral_; - //! index_t_ type: integral constant wrapper for \c index_t a.k.a std::size_t + //! index_ type: integral constant wrapper for \c index_t a.k.a std::size_t template - using index_t_ = integral_c; + using index_ = integral_; - //! size_t_ type: integral constant wrapper for \c size_t a.k.a std::size_t + //! size_ type: integral constant wrapper for \c size_t a.k.a std::size_t template - using size_t_ = integral_constant; + using size_ = integral_; //! Computes the size of the type \p _Tp. //! Complexity \f$ O(1) \f$. template - using sizeof_ = size_t_; + using sizeof_ = size_; //! Computes the alignment required for any instance of the type \p _Tp. //! Complexity \f$ O(1) \f$. template - using alignof_ = size_t_; + using alignof_ = size_; //! @} //! The last position we can express for indexing - using Npos = size_t_; + using Npos = size_; }} //!@} diff --git a/include/utl/meta/invoke.h b/include/utl/meta/invoke.h index 3d87f0b..020c4f1 100644 --- a/include/utl/meta/invoke.h +++ b/include/utl/meta/invoke.h @@ -1,6 +1,6 @@ /*! * \file invoke.h - * \brief Template meta-programming utilities + * \brief Template meta-programming utilities for callables * * Copyright (C) 2018 Christos Choutouridis * @@ -12,7 +12,7 @@ * 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. + * 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 . @@ -36,26 +36,10 @@ namespace utl { namespace meta{ /*! + * \name meta:: invoke * - * \name invoke - * All Metafunction classes shall contain apply, which is Metafunction - * - * Metafunction: - * A metafunction is a class or a class template that represents a function invocable at compile-time. - * An non-nullary metafunction is invoked by instantiating the class template with particular template - * parameters (metafunction arguments). The result of the metafunction application is accessible - * through the instantiation's nested type typedef. - * All metafunction's arguments must be types (i.e. only type template parameters are allowed). - * A metafunction can have a variable number of parameters. - * A nullary metafunction is represented as a (template) class with a nested type typename member. - * - * Metafunction Class: - * A metafunction class is a certain form of metafunction representation that enables higher-order - * metaprogramming. More precisely, it's a class with a publicly-accessible nested Metafunction called - * apply. Correspondingly, a metafunction class invocation is defined as invocation of its nested apply - * metafunction. - * - * Concept here is `Invokable` (contains apply metafunction) + * A meta-programming invoke() analogous. A meta:: `invocable` shall contain a nested + * template type named `apply` which is bind to actual invocable meta-function. */ //! @{ @@ -78,7 +62,7 @@ namespace meta{ //! identity type alias template - using identity_t = type_>; + using identity_t = eval>; //! @} //! Is applicable trait @@ -100,7 +84,7 @@ namespace meta{ template struct is_applicable_q_ { - template>> + template>> static Ret check (int); //< T.. can be passed to G template static nil_ check (...); //< all other combinations @@ -121,17 +105,17 @@ namespace meta{ //! check if we can instantiate \p F with parameters \p T template class F, typename... T> - using is_applicable_t = type_< + using is_applicable_t = eval< detail::is_applicable_ >; //! check if we can instantiate \p Q with parameters \p T and the instant //! is different from \c nil_ template - using is_applicable_qt = type_ < + using is_applicable_qt = eval < // Extra check for quoted metafunctions to check return type if_ < not_same_< - type_ >, + eval >, nil_ >, true_, @@ -140,7 +124,7 @@ namespace meta{ >; //! check if we can instantiate \p F with parameters \p Is of type \p T template class F, T... Is> - using is_applicable_it = type_< + using is_applicable_it = eval< detail::is_applicable_i_ >; @@ -199,7 +183,7 @@ namespace meta{ template