J
Jon
Is auto_ptr allowed in managed C++ class?
I have my doubts because of the following example:
#include "stdafx.h"
#include <iostream>
#include <memory>
using namespace std;
#using <mscorlib.dll>
using namespace System;
#pragma unmanaged
int ctorDtorCount = 0;
struct S {
S() {
++ctorDtorCount;
}
~S() {
--ctorDtorCount;
if( ctorDtorCount < 0 )
throw "Error";
}
};
auto_ptr<S> produce() {
return auto_ptr<S>( new S() );
};
void consume( auto_ptr<S> s ) {
}
#pragma managed
int _tmain()
{
consume( produce() );
return 0;
}
I have my doubts because of the following example:
#include "stdafx.h"
#include <iostream>
#include <memory>
using namespace std;
#using <mscorlib.dll>
using namespace System;
#pragma unmanaged
int ctorDtorCount = 0;
struct S {
S() {
++ctorDtorCount;
}
~S() {
--ctorDtorCount;
if( ctorDtorCount < 0 )
throw "Error";
}
};
auto_ptr<S> produce() {
return auto_ptr<S>( new S() );
};
void consume( auto_ptr<S> s ) {
}
#pragma managed
int _tmain()
{
consume( produce() );
return 0;
}