Browse Source

un/formatted() usage to un/formatted

jan p springer 12 years ago
parent
commit
39179ba1ad
3 changed files with 15 additions and 18 deletions
  1. 4 7
      glm/gtx/io.hpp
  2. 9 9
      glm/gtx/io.inl
  3. 2 2
      test/gtx/gtx_io.cpp

+ 4 - 7
glm/gtx/io.hpp

@@ -138,9 +138,6 @@ namespace glm
     typedef basic_format_saver<char>     format_saver;
     typedef basic_format_saver<wchar_t> wformat_saver;
     
-    struct formatted   { /* empty */ };
-    struct unformatted { /* empty */ };
-    
     struct precision {
 
       unsigned value;
@@ -178,11 +175,11 @@ namespace glm
 
     template <typename FTy, typename CTy, typename CTr>
     FTy const& get_facet(std::basic_ios<CTy,CTr>&);
+    template <typename FTy, typename CTy, typename CTr>
+    std::basic_ios<CTy,CTr>& formatted(std::basic_ios<CTy,CTr>&);
+    template <typename FTy, typename CTy, typename CTr>
+    std::basic_ios<CTy,CTr>& unformattet(std::basic_ios<CTy,CTr>&);
     
-    template <typename CTy, typename CTr>
-    std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, formatted const&);
-    template <typename CTy, typename CTr>
-    std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, unformatted const&);
     template <typename CTy, typename CTr>
     std::basic_ostream<CTy, CTr>& operator<<(std::basic_ostream<CTy, CTr>&, precision const&);
     template <typename CTy, typename CTr>

+ 9 - 9
glm/gtx/io.inl

@@ -119,21 +119,21 @@ namespace glm
     }
 
     template <typename CTy, typename CTr>
-    GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>&
-    operator<<(std::basic_ostream<CTy, CTr>& os, formatted const&)
+    GLM_FUNC_QUALIFIER std::basic_ios<CTy,CTr>&
+    formatted(std::basic_ios<CTy,CTr>& ios)
     {
-      const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy>>(os)).formatted = true;
+      const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy>>(ios)).formatted = true;
 
-      return os;
+      return ios;
     }
-
+    
     template <typename CTy, typename CTr>
-    GLM_FUNC_QUALIFIER std::basic_ostream<CTy, CTr>&
-    operator<<(std::basic_ostream<CTy, CTr>& os, unformatted const&)
+    GLM_FUNC_QUALIFIER std::basic_ios<CTy,CTr>&
+    unformatted(std::basic_ios<CTy,CTr>& ios)
     {
-      const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy>>(os)).formatted = false;
+      const_cast<format_punct<CTy>&>(get_facet<format_punct<CTy>>(ios)).formatted = false;
 
-      return os;
+      return ios;
     }
     
     template <typename CTy, typename CTr>

+ 2 - 2
test/gtx/gtx_io.cpp

@@ -80,7 +80,7 @@ int test_io_quat(OS& os)
   {
     glm::io::basic_format_saver<typename OS::char_type> const iofs(os);
   
-    os << glm::io::unformatted()
+    os << glm::io::unformatted
        << type_name<T,P>(os, q) << ": " << q << '\n';
   }  
 
@@ -157,7 +157,7 @@ int test_io_mat(OS& os)
      << "mat4x3<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat4x3<T,P>(v3_1, v3_2, v3_3, v3_4) << '\n'
      << "mat4x4<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat4x4<T,P>(v4_1, v4_2, v4_3, v4_4) << '\n';
   
-  os << glm::io::unformatted()
+  os << glm::io::unformatted
      << glm::io::order(glm::io::order_type::column_major)
      << "mat2x2<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat2x2<T,P>(v2_1, v2_2) << '\n'
      << "mat2x3<" << typeid(T).name() << ',' << P << ">: " << glm::detail::tmat2x3<T,P>(v3_1, v3_2) << '\n'