• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DNKpp / Simple-Utility / 6497034454

12 Oct 2023 02:27PM UTC coverage: 86.872% (-12.8%) from 99.712%
6497034454

Pull #71

github

web-flow
Merge 967744a15 into e4166ac5d
Pull Request #71: graph namespace

281 of 281 new or added lines in 17 files covered. (100.0%)

622 of 716 relevant lines covered (86.87%)

154.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/include/Simple-Utility/CRTPBase.hpp
1
//          Copyright Dominic Koepke 2019 - 2023.
2
// Distributed under the Boost Software License, Version 1.0.
3
//    (See accompanying file LICENSE_1_0.txt or copy at
4
//          https://www.boost.org/LICENSE_1_0.txt)
5

6
#ifndef SIMPLE_UTILITY_CRTP_BASE_HPP
7
#define SIMPLE_UTILITY_CRTP_BASE_HPP
8

9
#pragma once
10

11
#include "Simple-Utility/concepts/stl_extensions.hpp"
12

13
namespace sl
14
{
15
        /**
16
         * \brief Utility type, which can be used as a base class for the crtp pattern.
17
         * \tparam Derived The derived type.
18
         * \tparam Disambiguity In cases of multiple inheritance, this param can be used to disambiguity the base class.
19
         */
20
        template <concepts::unqualified Derived, class Disambiguity = void>
21
        class CRTPBase
22
        {
23
        protected:
24
                /**
25
                 * \brief Up-casts the this pointer to a const lvalue reference to ``Derived``.
26
                 * \return A const lvalue reference.
27
                 */
28
                [[nodiscard]]
29
                constexpr const Derived& derived() const noexcept
270✔
30
                {
31
                        return static_cast<const Derived&>(*this);
270✔
32
                }
33

34
                /**
35
                 * \brief Up-casts the this pointer to a lvalue reference to ``Derived``.
36
                 * \return A lvalue reference.
37
                 */
38
                [[nodiscard]]
39
                constexpr Derived& derived() noexcept
263✔
40
                {
41
                        return static_cast<Derived&>(*this);
263✔
42
                }
43

44
                /**
45
                 * \brief Default constructor, performing compile-time checks.
46
                 */
47
                constexpr CRTPBase() noexcept
278✔
48
                {
49
                        static_assert(std::is_base_of_v<CRTPBase, Derived>, "Derived doesn't inherit from CRTPBase.");
50
                }
278✔
51

52
                /**
53
                 * \brief Defaulted copy-constructor.
54
                 */
55
                CRTPBase(const CRTPBase&) = default;
56

57
                /**
58
                 * \brief Defaulted copy-assignment operator.
59
                 */
60
                CRTPBase& operator =(const CRTPBase&) = default;
61

62
                /**
63
                 * \brief Defaulted move-constructor.
64
                 */
65
                CRTPBase(CRTPBase&&) = default;
66

67
                /**
68
                 * \brief Defaulted move-assignment operator.
69
                 */
70
                CRTPBase& operator =(CRTPBase&&) = default;
71

72
                /**
73
                 * \brief Defaulted destructor.
74
                 */
75
                ~CRTPBase() = default;
76

77
                /**
78
                 * \brief Defaulted equality operator.
79
                 * \return Returns true, if both operators are equal.
80
                 */
81
                [[nodiscard]]
82
                constexpr bool operator ==(const CRTPBase&) const noexcept = default;
×
83
        };
84
}
85

86
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc