table_type.hpp 1.0 KB

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