Imported Upstream version 1.57.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 http://www.boost.org/LICENSE_1_
5
6 #ifndef BOOST_MP_TABLE_TYPE
7
8 #include <libs/math/test/table_type.hpp>
9 #include <boost/multiprecision/number.hpp>
10
11 struct string_table_entry
12 {
13 private:
14    const char* m_data;
15 public:
16    string_table_entry(const char* p) : m_data(p) {}
17
18    template <class T>
19    operator T () const
20    {
21       return static_cast<T>(m_data);
22    }
23 };
24
25 inline std::ostream& operator << (std::ostream& os, string_table_entry const & what)
26 {
27    return os << static_cast<const char*>(what);
28 }
29
30 template <class Backend, boost::multiprecision::expression_template_option ExpressionTemplates>
31 struct table_type<boost::multiprecision::number<Backend, ExpressionTemplates> >
32 {
33    typedef string_table_entry type;
34 };
35
36 #define SC_(x) string_table_entry(BOOST_STRINGIZE(x))
37
38 #endif
39