HP OpenVMS Systems

ask the wizard
Content starts here

C++ duplicate function declaration? (MEMFUNRED)

» close window

The Question is:

We think we have a problem with the C++ compiler
this example shows it:
#include <vector>
vector< int* const>::iterator it2;
This will produce:
PGVS4>cxx text.cc
    const_pointer address(const_reference x) const
%CXX-E-MEMFUNRED, function
          "std::allocator<T>::address(std::allocator<T>::reference) const
          [with T=int *const]" has already been declared
          detected during:
            instantiation of class "std::allocator<T> [with T=int *const]" at
                      line 110 of "Text library
                      SYS$COMMON:[SYSLIB]CXXL$ANSI_DEF.TLB;1 module VECTOR."
            instantiation of class "std::vector<T, Allocator> [with T=int
                      *const, Allocator=std::allocator<int *const>]" at line 5
                      of "USER$DISK:[RENE.JOBCMD]TEXT.CC;8"
at line number 407 in module MEMORY. of text library SYS$COMMON:[SYSLIB]CXXL$ANS
%CXX-I-MESSAGE, 1 error detected in the compilation of "USER$DISK:[RENE.JOBCMD]T
Any hints on how to resolve this?
BTW We are using CPP:
PGVS4>cxx /ver
Compaq C++ V6.2-016 for OpenVMS Alpha V7.2-1

The Answer is :

  This program violates the container element requirements of the STL.
  In particular, an element type must be Assignable, i.e. a type is
  assignable if it is possible to copy objects of that type and to
  assign values to variables of that type.
  If you look on page 84 (Section 6.1) of the book, "Generic Programming
  and the STL" by Matthew H. Austern you'll see the following explanation:
    "Almost all the built-in C++ types are models of Assignable, with the
    notable exception of const T. For example, int is a model of Assignable
    (it's possible to copy and assign values of type int) but const int is
    not. If x is declared to be of type const int, then x = 7 is illegal.
    You can copy a variable of type const int but you can't assign to it.
  Since the type int* const, a const pointer to int, is not assignable,
  the code in .0  is illegal.
  const int*, i.e. a non-const pointer to const int is assignable.

answer written or last revised on ( 8-JAN-2001 )

» close window