incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov" <Farid_Zari...@epam.com>
Subject RE: [PATCH] dynatype.cpp example and MSVC
Date Thu, 29 Mar 2007 16:45:16 GMT
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com] 
> Sent: Wednesday, March 28, 2007 10:35 PM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: [PATCH] dynatype.cpp example and MSVC
> 
> This looks familiar. Didn't I already review this patch?
> 
> [...searching archives...]
> 
> I see you original patch in our archive 
> (http://tinyurl.com/ywxq9w) but I can't find my reply there. 
> I was able to find it here though:
> http://www.mail-archive.com/stdcxx-dev@incubator.apache.org/ms
> g02760.html
> 
> but I haven't found any further follow-ups on the issues I 
> raised, either from you or anyone else.
> 

  I have not received the reply from you. 

>>     @@ -105,27 +105,19 @@
>> 
>>     // 14.7.3, p6 - explicit specializations must be defined before
first
>> 
>>     use
>>      template <>
>>     -inline void dynatype::remove<dynatype::map<void> >()
>>     +inline void dynatype::remove<void>()
>> 
> The replacement doesn't look equivalent to the original. Is it correct
> for compilers other than MSVC?

  Why not?

  The dynatype::remove<dynatype::map<void> > used only in default
constructor,
because the dynatype::map<void> type is private type, so here that type
can be
replaced to the type void.

  This change deals with MSVC error:
dynatype.cpp(109) : error C2248: 'dynatype::map<T>' : cannot access
private struct declared in class 'dynatype'
        with
        [
            T=void
        ]
        dynatype.cpp(31) : see declaration of 'dynatype'


  The dynatype::operator= (const dynatype::map<void>&) removed because
it's never used.

  The CREF macro used to resolve ambiguity between dynatype::operator T&
() and dynatype::operator T () const:

dynatype.cpp(188) : error C2440: 'type cast' : cannot convert from
'dynatype' to 'int'
        Ambiguous user-defined-conversion


> Btw., do you have a test case for the MSVC bug that prevents the code
from compiling?

The first test:
-----------------------------------
class test
{
    struct private_t;

    template <class T>
    int foo () {
        return 1;
    }
};

template <>
int test::foo<test::private_t> ()
{
    return 2;
}

int main ()
{
    return 0;
}
-----------------------------------

test.cpp(13) : error C2248: 'test::private_t' : cannot access private
struct declared in class 'test'
        test.cpp(3) : see declaration of 'test::private_t'
        test.cpp(2) : see declaration of 'test'


  The second test:

-----------------------------------
class test
{
public:
    template <class T>
    operator T& () {
        static T x_;
        return x_;
    }

    template <class T>
    operator T () const {
        return T (1);
    }
};

int main ()
{
    test t;
    int x = int (t);
    return 0;
}
-----------------------------------

test.cpp(19) : error C2440: 'type cast' : cannot convert from 'test' to
'int'
        Ambiguous user-defined-conversion


Farid.

Mime
View raw message