.. _program_listing_file_include_ciabatta_ciabatta.hpp: Program Listing for File ciabatta.hpp ===================================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/ciabatta/ciabatta.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright 2019 Gašper Ažman // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /* * CHANGELOG: * - Add explicit keyword to mixin constructor and remove * default constructor and assignment operators. * - Remove macro usage. * - Invert the argument order on the curry struct template to * support default template parameters. * - Re-implement mixin struct so it doesn't require CRTP to compose a new mixin. */ #ifndef CIABATTA_CIABATTA_HPP #define CIABATTA_CIABATTA_HPP namespace ciabatta { template struct ciabatta_top { /* not a mixin */ using self_type = MostDerived; [[nodiscard]] decltype(auto) self() & { return static_cast(*this); } [[nodiscard]] decltype(auto) self() && { return static_cast(*this); } [[nodiscard]] decltype(auto) self() const& { return static_cast(*this); } [[nodiscard]] decltype(auto) self() const&& { return static_cast(*this); } }; struct deferred { deferred() = delete; }; namespace detail { template class H, template class... Tail> struct chain_inherit { using result = typename chain_inherit::type; using type = H; }; template class H> struct chain_inherit { using type = H; }; template class... Mixins> using mixin_impl = typename chain_inherit, Mixins...>::type; } // namespace detail template class... Mixins> struct mixin_base : ::ciabatta::detail::mixin_impl { template constexpr explicit mixin_base(Rest&&... rest) : ::ciabatta::detail::mixin_impl(static_cast(rest)...) {} }; template