Operating System - Linux
1828227 Members
2673 Online
109975 Solutions
New Discussion

vector initialization with

 
sanjai
Occasional Contributor

vector initialization with

I'm using a stl::vector to maintain list.
Program fails during compilation time when the template class's overloaded address operator is private.
When it's made public files get compiled without a problem. However the same test program gets compiled with the VC compiler in Windows. Is this a stl implementation specific issue in HP-UX.


My test files are as follows

// Test.h: file
//
//////////////////////////////////////////////////////////////////////

#if !defined(_TEST_HDR_)
#define _TEST_HDR_



class CTest
{
public:
CTest();
virtual ~CTest();
private:
CTest * operator&();
};

#endif //

// Test.cpp: implementation of the CTest class.
//
//////////////////////////////////////////////////////////////////////


#include "Test.h"


//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CTest::CTest()
{

}

CTest::~CTest()
{

}

CTest * CTest::operator&()
{
return this;
}

///// mytest.h file


#ifndef __MYTEST_H__
#define __MYTEST_H__

#include
#include

#include "Test.h"

class mytest
{

public:
mytest();
int test(int a);
std::vector mNodeMap;

};

#endif //MYTEST



//mytest.cpp file




#include "mytest.h"

mytest::mytest()
{
mNodeMap.resize(30);
}

int mytest::test(int a)
{


return a;
}


version of aCC compiler I'm using is
A.03.33



1 REPLY 1
Dennis Handly
Acclaimed Contributor

Re: vector initialization with

It appears your T violates 23.1(3), it has to be CopyConstructable. Table 30 in 20.1.3(1) says that &t returns *T. And I assume it better not be private.

I've heard from Roguewave on this and he said sometimes there are changes that can be made to allow this but is isn't required by the Standard.