Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73481 - in trunk: boost/locale libs/locale/src/encoding libs/locale/test
From: artyomtnk_at_[hidden]
Date: 2011-08-01 15:29:18


Author: artyom
Date: 2011-08-01 15:29:17 EDT (Mon, 01 Aug 2011)
New Revision: 73481
URL: http://svn.boost.org/trac/boost/changeset/73481

Log:
Fixing an issue with incorrect use of templated member functions

Removed:
   trunk/boost/locale/utf_encoding.hpp
Text files modified:
   trunk/boost/locale/encoding_utf.hpp | 7 ++++---
   trunk/libs/locale/src/encoding/wconv_codepage.ipp | 2 +-
   trunk/libs/locale/test/test_utf.cpp | 4 ++--
   3 files changed, 7 insertions(+), 6 deletions(-)

Modified: trunk/boost/locale/encoding_utf.hpp
==============================================================================
--- trunk/boost/locale/encoding_utf.hpp (original)
+++ trunk/boost/locale/encoding_utf.hpp 2011-08-01 15:29:17 EDT (Mon, 01 Aug 2011)
@@ -35,16 +35,17 @@
             {
                 std::basic_string<CharOut> result;
                 result.reserve(end-begin);
- std::back_insert_iterator<std::basic_string<CharOut> > inserter(result);
+ typedef std::back_insert_iterator<std::basic_string<CharOut> > inserter_type;
+ inserter_type inserter(result);
                 utf::code_point c;
                 while(begin!=end) {
- c=utf::utf_traits<CharIn>::template decode(begin,end);
+ c=utf::utf_traits<CharIn>::template decode<CharIn const *>(begin,end);
                     if(c==utf::illegal || c==utf::incomplete) {
                         if(how==stop)
                             throw conversion_error();
                     }
                     else {
- utf::utf_traits<CharOut>::template encode(c,inserter);
+ utf::utf_traits<CharOut>::template encode<inserter_type>(c,inserter);
                     }
                 }
                 return result;

Deleted: trunk/boost/locale/utf_encoding.hpp
==============================================================================
--- trunk/boost/locale/utf_encoding.hpp 2011-08-01 15:29:17 EDT (Mon, 01 Aug 2011)
+++ (empty file)
@@ -1,97 +0,0 @@
-//
-// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-#ifndef BOOST_LOCALE_ENCODING_HPP_INCLUDED
-#define BOOST_LOCALE_ENCODING_HPP_INCLUDED
-
-#include <boost/locale/utf.hpp>
-#include <boost/locale/encoding_erros.hpp>
-
-#ifdef BOOST_MSVC
-# pragma warning(push)
-# pragma warning(disable : 4275 4251 4231 4660)
-#endif
-
-
-namespace boost {
- namespace locale {
- namespace conv {
- ///
- /// \addtogroup codepage Character conversion functions
- ///
- /// @{
-
- ///
- /// Convert a Unicode text in range [begin,end) to other Unicode encoding
- ///
- /// This function does not require linking with Boost.Locale library
- ///
- template<typename CharOut,typename CharIn>
- std::basic_string<CharOut>
- utf_to_utf(CharIn const *begin,CharIn const *end,method_type how = default_method)
- {
- std::basic_string<CharOut> result;
- result.reserve(end-begin);
- std::back_insert_iterator<std::basic_string<CharOut> > inserter(result);
- utf::code_point c;
- while(begin!=end) {
- c=utf::utf_traits<CharIn>::template decode(begin,end);
- if(c==utf::illegal || c==utf::incomplete) {
- if(how==stop)
- throw conversion_error();
- }
- else {
- utf::utf_traits<CharOut>::template encode(c,inserter);
- }
- }
- return result;
- }
-
- ///
- /// Convert a Unicode NUL terminated string \a str other Unicode encoding
- ///
- /// This function does not require linking with Boost.Locale library
- ///
- template<typename CharOut,typename CharIn>
- std::basic_string<CharOut>
- utf_to_utf(CharIn const *str,method_type how = default_method)
- {
- CharIn const *end = str;
- while(*end)
- end++;
- return utf_to_utf<CharOut,CharIn>(str,end,how);
- }
-
-
- ///
- /// Convert a Unicode string \a str other Unicode encoding
- ///
- /// This function does not require linking with Boost.Locale library
- ///
- template<typename CharOut,typename CharIn>
- std::basic_string<CharOut>
- utf_to_utf(std::basic_string<CharIn> const &str,method_type how = default_method)
- {
- return utf_to_utf<CharOut,CharIn>(str.c_str(),str.c_str()+str.size(),how);
- }
-
-
- /// @}
-
- } // conv
-
- } // locale
-} // boost
-
-#ifdef BOOST_MSVC
-#pragma warning(pop)
-#endif
-
-#endif
-
-// vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
-

Modified: trunk/libs/locale/src/encoding/wconv_codepage.ipp
==============================================================================
--- trunk/libs/locale/src/encoding/wconv_codepage.ipp (original)
+++ trunk/libs/locale/src/encoding/wconv_codepage.ipp 2011-08-01 15:29:17 EDT (Mon, 01 Aug 2011)
@@ -205,7 +205,7 @@
         CharType const *begin = str;
         CharType const *end = str+len;
         while(begin!=end) {
- utf::code_point c = utf::utf_traits<CharType,2>::template decode(begin,end);
+ utf::code_point c = utf::utf_traits<CharType,2>::template decode<CharType const *>(begin,end);
             if(c==utf::illegal || c==utf::incomplete)
                 return false;
         }

Modified: trunk/libs/locale/test/test_utf.cpp
==============================================================================
--- trunk/libs/locale/test/test_utf.cpp (original)
+++ trunk/libs/locale/test/test_utf.cpp 2011-08-01 15:29:17 EDT (Mon, 01 Aug 2011)
@@ -78,7 +78,7 @@
     
     TEST(tr::max_width == 4 / sizeof(CharType));
 
- TEST(tr::template decode(begin,end) == codepoint);
+ TEST(tr::template decode<CharType const *>(begin,end) == codepoint);
 
     if(codepoint == incomplete || codepoint != illegal)
         TEST(end == begin);
@@ -111,7 +111,7 @@
 {
     CharType buf[5] = {1,1,1,1,1};
     CharType *p=buf;
- p = utf_traits<CharType>::template encode(codepoint,p);
+ p = utf_traits<CharType>::template encode<CharType *>(codepoint,p);
     CharType const *end = str;
     while(*end)
         end++;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk