CNL  2.0.2 (development)
Compositional Numeric Library
All Classes Namespaces Files Functions Variables Typedefs Macros Pages
to_rep.h
1 
2 // Copyright John McFarlane 2019.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file ../LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 
7 #if !defined(CNL_IMPL_WRAPPER_TO_REP_H)
8 #define CNL_IMPL_WRAPPER_TO_REP_H
9 
10 #include "../num_traits/rep_of.h"
11 #include "../num_traits/to_rep.h"
12 #include "is_wrapper.h"
13 
15 namespace cnl {
16  template<_impl::any_wrapper Number>
17  struct to_rep<Number> {
18  using rep_type = _impl::rep_of_t<Number>;
19 
20  [[nodiscard]] constexpr auto& operator()(Number& n) const
21  {
22  return n._rep;
23  }
24 
25  [[nodiscard]] constexpr auto const& operator()(Number const& n) const
26  {
27  return n._rep;
28  }
29 
30  [[nodiscard]] constexpr auto&& operator()(Number&& n) const
31  {
32  return std::forward<rep_type>(n._rep);
33  }
34  };
35 }
36 
37 #endif // CNL_IMPL_WRAPPER_TO_REP_H
cnl
compositional numeric library
Definition: abort.h:15