From 2e825630f8266f7cb26eef80bc08556a16dd460a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20J=C3=A4rvi?= Date: Wed, 12 Dec 2001 21:35:41 +0000 Subject: [PATCH] made the iomanipulator storage indexes static members of a class. Now all code can be in header files. [SVN r12020] --- include/boost/tuple/tuple_io.hpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/include/boost/tuple/tuple_io.hpp b/include/boost/tuple/tuple_io.hpp index 64514f0..188d43d 100644 --- a/include/boost/tuple/tuple_io.hpp +++ b/include/boost/tuple/tuple_io.hpp @@ -45,11 +45,19 @@ namespace detail { class format_info { public: + enum manipulator_type { open, close, delimiter }; BOOST_STATIC_CONSTANT(int, number_of_manipulators = delimiter + 1); private: - static const int stream_index[number_of_manipulators]; + static int get_stream_index (int m) + { + static const int stream_index[number_of_manipulators] + = { std::ios::xalloc(), std::ios::xalloc(), std::ios::xalloc() }; + + return stream_index[m]; + } + format_info(const format_info&); format_info(); @@ -58,7 +66,7 @@ public: #if defined (BOOST_NO_TEMPLATED_STREAMS) static char get_manipulator(std::ios& i, manipulator_type m) { - char c = static_cast(i.iword(stream_index[m])); + char c = static_cast(i.iword(get_stream_index(m))); // parentheses and space are the default manipulators if (!c) { @@ -72,7 +80,7 @@ public: } static void set_manipulator(std::ios& i, manipulator_type m, char c) { - i.iword(stream_index[m]) = static_cast(c); + i.iword(get_stream_index(m)) = static_cast(c); } #else template @@ -82,7 +90,7 @@ public: // A valid instanitation of basic_stream allows CharType to be any POD, // hence, the static_cast may fail (it fails if long is not convertible // to CharType - CharType c = static_cast(i.iword(stream_index[m]) ); + CharType c = static_cast(i.iword(get_stream_index(m)) ); // parentheses and space are the default manipulators if (!c) { switch(m) { @@ -102,7 +110,7 @@ public: // A valid instanitation of basic_stream allows CharType to be any POD, // hence, the static_cast may fail (it fails if CharType is not // convertible long. - i.iword(stream_index[m]) = static_cast(c); + i.iword(get_stream_index(m)) = static_cast(c); } #endif // BOOST_NO_TEMPLATED_STREAMS };