another small thing

Levente Farkas lfarkas@mindmaker.hu
Thu Aug 17 03:50:00 GMT 2000


and here is the patch if it's ok for you.
anyway why do we use __ in local variable and parameter names ?

Levente Farkas wrote:
> 
> -------------------
> #include <cmath>
> #include <string>
> 
> int main()
> {
>   std::string s("xxx");
>   return 0;
> }
> -------------------
> g++ -Wshadow test.cpp
> is give the error for me (ok if I miss the -Wshadow...:_)
> 
> Benjamin Kosnik wrote:
> >
> > can't reproduce this with this simple test case
> >
> > #include <cmath>
> > #include <string>
> >
> > int main()
> > {
> >   using namespace std;
> >
> >   string test("miles, kind of blue");
> >   return 0;
> > }
> >
> > Perhaps you could provide more detail?
> >
> > -benjamin
> >
> > > `std::basic_string<_CharT, _Traits, _Alloc>::basic_string (const _CharT *, const
> > > _Alloc &) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc =
> > > std::allocator<char>]'
> > > /usr/include/g++-v3/bits/locale_facets.h:1311:   instantiated from here
> > > /usr/include/g++-v3/bits/basic_string.h:301: warning: declaration of `__j1'
> > > shadows global declaration
> > > -------------------------
> > > what is the global __j1 anyway ? it's come from math.h with friends:
> > > j0 j1 jn y0 y1 yn
> > > the soulution would be to not include cmath before string, but:-((
> 
> --
>  -- Levente
>  "The only thing worse than not knowing the truth is
>   ruining the bliss of ignorance."

-- 
 -- Levente
 "The only thing worse than not knowing the truth is
  ruining the bliss of ignorance."
--- libstdc++-v3/bits/basic_string.h.lfarkas	Thu Aug 17 12:29:11 2000
+++ libstdc++-v3/bits/basic_string.h	Thu Aug 17 12:43:24 2000
@@ -278,27 +278,27 @@
       // to optimize for the common case of pointers as iterators.
       template<class _Iterator>
         static void
-        _S_copy_chars(_CharT* __p, _Iterator __j1, _Iterator __j2)
+        _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
         { 
-	  for (; __j1 != __j2; ++__j1, ++__p) 
-	    traits_type::assign(*__p, *__j1); //these types are off
+	  for (; __k1 != __k2; ++__k1, ++__p) 
+	    traits_type::assign(*__p, *__k1); //these types are off
 	}
 
       static void
-      _S_copy_chars(_CharT* __p, iterator __j1, iterator __j2)
-      { _S_copy_chars(__p, __j1.base(), __j2.base()); }
+      _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2)
+      { _S_copy_chars(__p, __k1.base(), __k2.base()); }
 
       static void
-      _S_copy_chars(_CharT* __p, const_iterator __j1, const_iterator __j2)
-      { _S_copy_chars(__p, __j1.base(), __j2.base()); }
+      _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
+      { _S_copy_chars(__p, __k1.base(), __k2.base()); }
  
       static void
-      _S_copy_chars(_CharT* __p, _CharT* __j1, _CharT* __j2)
-      { traits_type::copy(__p, __j1, __j2 - __j1); }
+      _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2)
+      { traits_type::copy(__p, __k1, __k2 - __k1); }
 
       static void
-      _S_copy_chars(_CharT* __p, const _CharT* __j1, const _CharT* __j2)
-      { traits_type::copy(__p, __j1, __j2 - __j1); }
+      _S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2)
+      { traits_type::copy(__p, __k1, __k2 - __k1); }
 
       void 
       _M_mutate(size_type __pos, size_type __len1, size_type __len2);
@@ -636,20 +636,20 @@
       template<class _InputIterator>
         basic_string& 
         replace(iterator __i1, iterator __i2,
-		_InputIterator __j1, _InputIterator __j2)
-        { return _M_replace(__i1, __i2, __j1, __j2,
+		_InputIterator __k1, _InputIterator __k2)
+        { return _M_replace(__i1, __i2, __k1, __k2,
 	     typename iterator_traits<_InputIterator>::iterator_category()); }
 
     private:
       template<class _InputIterator>
         basic_string& 
-        _M_replace(iterator __i1, iterator __i2, _InputIterator __j1, 
-		   _InputIterator __j2, input_iterator_tag);
+        _M_replace(iterator __i1, iterator __i2, _InputIterator __k1, 
+		   _InputIterator __k2, input_iterator_tag);
 
       template<class _FwdIterator>
         basic_string& 
-        _M_replace(iterator __i1, iterator __i2, _FwdIterator __j1, 
-		   _FwdIterator __j2, forward_iterator_tag);
+        _M_replace(iterator __i1, iterator __i2, _FwdIterator __k1, 
+		   _FwdIterator __k2, forward_iterator_tag);
 
       // _S_construct_aux is used to implement the 21.3.1 para 15 which
       // requires special behaviour if _InIter is an integral type


More information about the Libstdc++ mailing list