stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Travis Vitek" <tvi...@quovadx.com>
Subject RE: svn commit: r573119 - /incubator/stdcxx/trunk/tests/regress/24.operations.stdcxx-234.cpp
Date Wed, 12 Sep 2007 23:31:43 GMT
 
This regression test fails to compile on more than one platform for
varying reasons.

    ..\..\..\..\tests\containers\t.cpp(9) : error C2785:
'iterator_traits<_Iterator>::difference_type
std::distance(_ForwardIterator,_ForwardIterator)' and 'int
distance(X,X)' have different return types
        c:\build\stdcxx\include\rw/_iterbase.h(341) : see declaration of
'std::distance'
        ..\..\..\..\tests\containers\t.cpp(9) : see declaration of
'distance'
    ..\..\..\..\tests\containers\t.cpp(9) : error C2244: 'std::distance'
: unable to match function definition to an existing declaration

It appears that MSVC doesn't like that you haven't provided the template
parameter types for the specialization of distance().

 
/amd/devco/vitek/stdcxx/trunk/tests/regress/24.operations.stdcxx-234.cpp
:38: error: specialization of `template<class _ForwardIterator> typename
std::iterator_traits::difference_type std::distance(_ForwardIterator,
_ForwardIterator)' in different namespace
  /amd/devco/vitek/stdcxx/trunk/include/rw/_iterbase.h:342: error:
from definition of `template<class _ForwardIterator> typename
std::iterator_traits::difference_type std::distance(_ForwardIterator,
_ForwardIterator)'
  gmake: *** [24.operations.stdcxx-234.o] Error 1

It looks like gcc doesn't like how you've put the distance()
specialization into namespace std. It appears that this is supposed to
be legal [14.7.3 p9], but gcc rejects the code.

I'm attaching a patch that I've tested on VC8 and gcc 3.4.6. It should
also compile on.


2007-09-12  Travis Vitek  <vitek@roguewave.com>

	* 24.operations.stdcxx-234.cpp: change to get regression
	test to correctly compile on gcc and msvc.

Index: 24.operations.stdcxx-234.cpp
===================================================================
--- 24.operations.stdcxx-234.cpp	(revision 573323)
+++ 24.operations.stdcxx-234.cpp	(working copy)
@@ -31,13 +31,18 @@
 
 struct X: std::iterator<std::random_access_iterator_tag, int> { };
 
+namespace std {
+
 // specialize the std::distance() function template of a user-defined
 // iterator type to verify that the signature of the primary template
 // is the same as the one of the specialization
 template <> std::iterator_traits<X>::difference_type
-std::distance (X, X) { return 0; }
+distance<X> (X, X) { return 0; }
 
+} // namespace std
+
 int main ()
 {
     return std::distance (X (), X ());
 }
+



>-----Original Message-----
>From: sebor@apache.org [mailto:sebor@apache.org] 
>Sent: Wednesday, September 05, 2007 5:30 PM
>To: stdcxx-commits@incubator.apache.org
>Subject: svn commit: r573119 - 
>/incubator/stdcxx/trunk/tests/regress/24.operations.stdcxx-234.cpp
>
>Author: sebor
>Date: Wed Sep  5 17:30:13 2007
>New Revision: 573119
>
>URL: http://svn.apache.org/viewvc?rev=573119&view=rev
>Log:
>2007-09-06  Martin Sebor  <sebor@roguewave.com>
>
>	* 24.operations.stdcxx-234.cpp: Added a regression test 
>for STDCXX-234.
>
>

Mime
View raw message