Operating System - HP-UX
1751894 Members
5478 Online
108783 Solutions
New Discussion юеВ

Error #2289: no instance of constructor "customClass::customClass" matches the argument list

 
SOLVED
Go to solution
Skandh
Occasional Contributor

Error #2289: no instance of constructor "customClass::customClass" matches the argument list

I am compiling following code on HPUX-IA64 using aCC compiler:

bash-3.00$ uname -m
ia64
bash-3.00$ aCC -V
aCC: HP C/aC++ B3910B A.06.14 [Feb 22 2007]

#include
#include
#include
using namespace std;

class customClass
{
public:
customClass() {}
};

template
class CustomAllocator
{
public:
typedef T value_type;
typedef value_type * pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;

template struct rebind {
typedef CustomAllocator other;
};

template CustomAllocator
(const CustomAllocator& another)
{

}

explicit CustomAllocator()
{
}

pointer address(reference x) { return &x; }
const_pointer address(const_reference x) const { return &x; }
// n is permitted to be 0. The C++ standard says nothing about what the return value is when n == 0.
T* allocate(size_type n, const void* p = 0) const
{
return n != 0 ? reinterpret_cast (malloc(n * sizeof(value_type))) : 0;
}
//T* allocate(size_type n, const char* pFile, int nLine, const void* p = 0) const
//{
// return n != 0 ? reinterpret_cast (malloc(n * sizeof(value_type))) : 0;
//}
// p is permitted to be a null pointer, only if n==0.
void deallocate(pointer p, size_type n) const
{
if (p != 0) free(p);
}

bool operator==(const CustomAllocator& rOther) const
{
return true;
}

void destroy(pointer _Ptr)
{ // destroy object at _Ptr
if(_Ptr)
_Ptr->~T();
}

void construct(pointer _Ptr, const value_type& _Val)
{ // construct object at _Ptr with value _Val
new (_Ptr) T(_Val);
}

size_t max_size() const
{ // estimate maximum array size
size_t count = (size_t)(-1) / sizeof(T);
return (0 < count ? count : 1);
}
};


int main()
{
map , CustomAllocator > > myMap;
}

I am getting following error :

"/usr/local/remote/packages/compiler_remote/ansicA.06.14_aCC.A.06.14/opt/aCC/include_std/utility", line 117: error #2289:
no instance of constructor "customClass::customClass" matches the
argument list
argument types are: (const std::pair std::less, CustomAllocator<:pair> customClass>>>::key_type, std::map std::less, CustomAllocator<:pair> customClass>>>::mapped_type>::second_type)
: first (__rhs.first), second (__rhs.second) { }
^
detected during:
instantiation of "std::pair<_TypeT, _TypeU>::pair(const
std::pair<_TypeX, _TypeY> &) [with _TypeT=int,
_TypeU=customClass, _TypeX=const std::map std::less, CustomAllocator<:pair> customClass>>>::key_type, _TypeY=std::map std::less, CustomAllocator<:pair> customClass>>>::mapped_type]" at line 454 of
"/usr/local/remote/packages/compiler_remote/ansicA.06.14_
aCC.A.06.14/opt/aCC/include_std/rw/tree"
instantiation of "void __rw::__rb_tree<_Key, _Val, _KeyOf, _Comp,
_Alloc>::_C_put_node(__rw::__rb_tree<_Key, _Val, _KeyOf,
_Comp, _Alloc>::_C_link_type, bool) [with
_Key=std::map,
CustomAllocator<:pair>>>::key_type,
_Val=std::map,
CustomAllocator<:pair>
customClass>>>::value_type,
_KeyOf=__rw::__select1st<:map>
std::less, CustomAllocator<:pair> customClass>>>::value_type, std::map std::less, CustomAllocator<:pair> customClass>>>::key_type>, _Comp=std::map std::less, CustomAllocator<:pair> customClass>>>::key_compare, _Alloc=std::map std::less, CustomAllocator<:pair> customClass>>>::allocator_type]" at line 749 of
"/usr/local/remote/packages/compiler_remote/ansicA.06.14_
aCC.A.06.14/opt/aCC/include_std/rw/tree"

While same code compiles fine without

While same code compiles fine with g++ compiler :

bash-3.00$ g++ -v
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-11.0.1)


2 REPLIES 2
Dennis Handly
Acclaimed Contributor
Solution

Re: Error #2289: no instance of constructor "customClass::customClass" matches the argument list

>A.06.14

This is obsolete and not supported. The latest version is A.06.25.02.

map, CustomAllocator > > myMap;

In general your map container should have an allocator that looks something like:
CustomAllocator >

Why are you trying to use customClass?

>While same code compiles fine with g++ compiler

Perhaps is isn't checking? Or it depends on the STL implementation. I.e. your code isn't portable.
Skandh
Occasional Contributor

Re: Error #2289: no instance of constructor "customClass::customClass" matches the argument list

Thanks Very Much for your quick reply..