SeqAn3  3.2.0
The Modern C++ library for sequence analysis.
customisation_point.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2022, Knut Reinert & MPI für molekulare Genetik
4 // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5 // shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6 // -----------------------------------------------------------------------------------------------------
7 
13 #pragma once
14 
15 #include <seqan3/core/platform.hpp>
16 
17 namespace seqan3::detail
18 {
19 
20 // ============================================================================
21 // priority_tag
22 // ============================================================================
23 
26 template <size_t I>
27 struct priority_tag
29  // Doxygen fail
30  : priority_tag<I - 1>
32 {};
33 
35 template <>
36 struct priority_tag<0>
37 {};
38 
39 } // namespace seqan3::detail
40 
41 // ============================================================================
42 // SEQAN3_CPO_OVERLOAD
43 // ============================================================================
44 #if SEQAN3_DOXYGEN_ONLY(1) 0
62 # define SEQAN3_CPO_OVERLOAD_BODY(...) \
63  noexcept(auto) \
64  { \
65  return __VA_ARGS__; \
66  }
67 #else // ^^^ (simplified) doxygen version / normal definition vvv
68 # define SEQAN3_CPO_OVERLOAD_BODY(...) \
69  noexcept(noexcept(__VA_ARGS__))->decltype(__VA_ARGS__) \
70  { \
71  return __VA_ARGS__; \
72  } \
73  static_assert(true)
74 #endif
75 
107 #define SEQAN3_CPO_OVERLOAD(...) cpo_overload(__VA_ARGS__) SEQAN3_CPO_OVERLOAD_BODY
108 
109 namespace seqan3::detail
110 {
139 template <typename derived_t, unsigned max_priority>
140 struct customisation_point_object
141 {
142 private:
144  friend derived_t;
145 
146  constexpr customisation_point_object() = default;
147  constexpr customisation_point_object(customisation_point_object &&) = default;
148  constexpr customisation_point_object(customisation_point_object const &) = default;
149  constexpr customisation_point_object & operator=(customisation_point_object &&) = default;
150  constexpr customisation_point_object & operator=(customisation_point_object const &) = default;
151 
152 public:
163  template <typename... args_t, typename derived_type = derived_t /*circumvent incomplete types*/>
164  constexpr auto operator()(args_t &&... args) const SEQAN3_CPO_OVERLOAD_BODY(
165  /*return*/ derived_type::cpo_overload(priority_tag<max_priority>{}, std::forward<args_t>(args)...) /*;*/
166  );
167 };
168 } // namespace seqan3::detail
#define SEQAN3_CPO_OVERLOAD_BODY(...)
A macro helper for SEQAN3_CPO_OVERLOAD.
Definition: customisation_point.hpp:62
Provides platform and dependency checks.