Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / multiprecision / test / math / table_type.hpp
1 ///////////////////////////////////////////////////////////////
2 //  Copyright 2012 John Maddock. Distributed under the Boost
3 //  Software License, Version 1.0. (See accompanying file
4 //  LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
5
6 #ifndef BOOST_MP_TABLE_TYPE
7 #define BOOST_MP_TABLE_TYPE
8
9 #include <libs/math/test/table_type.hpp>
10 #include <boost/multiprecision/number.hpp>
11
12 struct string_table_entry
13 {
14  private:
15    const char* m_data;
16
17  public:
18    string_table_entry(const char* p) : m_data(p) {}
19
20    template <class T>
21    operator T() const
22    {
23       return static_cast<T>(m_data);
24    }
25 };
26
27 inline std::ostream& operator<<(std::ostream& os, string_table_entry const& what)
28 {
29    return os << static_cast<const char*>(what);
30 }
31
32 template <class Backend, boost::multiprecision::expression_template_option ExpressionTemplates>
33 struct table_type<boost::multiprecision::number<Backend, ExpressionTemplates> >
34 {
35    typedef string_table_entry type;
36 };
37
38 #define SC_(x) string_table_entry(BOOST_STRINGIZE(x))
39
40 #endif