Ambiguity in overloaded operator

Hi All,
Compiler barfs regards the overloaded operator [] .
#include <iostream>
#include <string>
class String {
  public:
    String() { }
    String(const char* src) : myStr(src) { }
    String(const std::string& src) : myStr(src) { }
    String(const String& src) : myStr(src.myStr) { }
    operator const char*() const         { return myStr.c_str(); }
    char& operator[](size_t index)       { return myStr[index]; }
    char operator[] (size_t index) const { return myStr[index]; }
    size_t length() const { return myStr.length(); }
  private:
    std::string myStr;
int main() {
    String s("abcd");
    char c = s[1];
    std::cout << c << std::endl;
    return 0;
$ CC -m32 -g ambiguous.cc
"ambiguous.cc", line 23: Error: Overloading ambiguity between "String::operator[](unsigned)" and "operator[](const char*, int)".
1 Error(s) detected.1) I cannot modify all the instances like, c = s[1]. There are hundreds of similar things in code.
2) operator const char* is required.
Could someone suggest any work-around, considering the above 2 points.
Thanks,
Sreekar

If you have both an operator char*() and and operator[](), you will have generally have overloading ambiguities. Adding more overloads as you did might cure some of them, but apart from complicating the code and reducing maintainability, can wind up with other ambiguities down the line.
The standard string class does not have an operator char*(), but a named conversion operator c_str() instead, partly for that reason, but mostly to prevent accidental and unintended conversions from string to char*. As designed, the String class in the example suffers from both defects.
The best fix is to re-think the design of the String class. If you are under pressure to get something working and out the door now, you could settle for a workaround such as you found. But make the time later to re-design and re-code. Otherwise the problems with the existing design will continue to cause problems, including code that mysteriously fails at run time, in the future.

Similar Messages

  • Overload operator new in C++ plugins

    Hi,
    Does it make sense to overload "operator new" in C++ plugins and have it call the Premiere memory allocation routines?
    Thanks!

    Hi Annabella,
    Yes, this could be done, although not necessarily required.  Remember though, when allocating buffers for video frames, to specifically use the PPix Creator Suite in PrSDKPPixCreatorSuite.h.  This will ensure that the created PPixes are stored in the Media Cache.
    Regards,
    Zac

  • Overloaded operations in OSB..

    Hi,
    I have a .net web service. Its WSDL has defined overloaded operations. But when i create business service using the WSDL in OSB, OSB reflects one operation only when i create branching. Is OSB (10.3.1) able to handled overloaded operations?
    Thanks,
    Kuppusamy.V.,
    Edited by: Ichiban_indian on Jun 14, 2010 6:09 PM

    Hi Kuppusamy,
    I am not able to see the WSDL as my n/w has blocked this site but just wanted to know whether you tested operations using SOAPUI? Are you getting proper response when you post request through SOAPUI?
    I am asking this question because web-service overloading has always caused issues (specially with .net web-service on webmethods) and if I am not wrong then it is NOT recommended to use overloading in web-services.
    You may consider raising a SR with Oracle Support, in parallel.
    Regards,
    Anuj

  • How to overload = operator in Java?

    Like String s = "somestring" or Integer i=10, how to develop a class with '=' operator overloaded?
    For example
    MyClass obj = 12.3f;(similar to Float class)

    I understand the answer. But how are these classes
    like String, Integer and other wrapper classes built
    for = operator overloading? Is this accomplished
    using native code?It's just how the language is defined. [url http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html]The JLS defines how these operators are required to behave. The compiler interpets them as per the JLS, to generate the proper bytecodes.

  • Built-in overloaded operator

    what is built-in overloading in java.
    explain me with example.

    what is built-in overloading in java.
    explain me with example.I may be responsible for that but it isn't an established term. Java has a number of operators working on primitive types, but Java doesn't have overloading so you can't redefine them and make them work on your own classes. There's an intermediate case though and that's the + opererator working on String, like
    String s = "this" + "that";This could be called "built-in" overloading I'd say. I think BigNumber is a strong candidate to given its own set of operators, maybe in version 1.6.

  • Wrong overloading ambiguity error

    Hi,
    The following compiles on Studio 7, but not on Studio 11, where an error is reported:
    Error: Overloading ambiguity between "myString::operator char*&()" and "myString::operator char*()"
    However, when myStr is defined const, then the code compiles.
    Why this difference in the behaviour of the compilers? Is it intended? Should unaccesible operators be checked for ambiguity? Why does the compiler check for ambiguity of methods which it obviously should not select in this case?
    #include <string.h>
    class myString {
      private:
         char * content;
      public:
         myString(const char * str) { content = new char[strlen(str)+1]; strcpy(content,str);};
         operator char*&() { char * cpy = new char[strlen(content)+1]; strcpy(cpy,content); return cpy;};
         operator const char* () const {return content;};
      private:
         operator char*() { char * cpy = new char[strlen(content)+1]; strcpy(cpy,content); return cpy;};
    int main() {
         myString myStr = "MyString Test String"; // COMPILE ERROR HERE
         const char * str = myStr;
         return 0;
    };

    The error is not on the marked line, but on the next
    line:
    const char * str = myStr;Yes, you are right, I marked the wrong line.
    >
    The rule for resolving overloaded functions is that
    all visible functions that can be called with the
    given arguments ("viable functions" in the
    terminology of the standard) are checked, and the
    best match is looked for.
    If there is no single best match, the call is
    ambiguous, an error.
    Only if there is a best match is accessibility
    checked. If the best match is not accessible, the
    call is in error.In this case, wouldn't the const operator be the best match?
    >
    The reason for checking accessibility last is to
    prevent changes in accessibility from changing the
    result of operator overload resoution. One can
    imagine different rules, but that is the C++ rule.
    (C++ Standard, section 13.3)This should only apply here if the compiler decided not to select the constant operator over the other operators. That would mean that doing two conversions (MyString -> char*/& -> const char*) would be preferred over doing one conversion (MyString -> const char *).
    Does this conform to the C++ standard rules?

  • Enum operator overloads not called

    Hi,
    we are faced with a serious problem of the current Forte C++ compiler version (WS6U2 with actual patches). The following test program shows that the compiler does not accept operator overloads for enums. Instead of this all enums are implicitly converted to int.
    The sample compiles and runs fine with three calls to the overloaded operator|() on other compilers such as g++. The funny thing ist that also the unpatched WS6U2 Forte C++ compiler (5.3 2001/05/15) works properly here.
    So, what are the concerns of the newer compiler versions from Sun? From our point the code should be accepted by an ISO C++ compliant compiler.
    $ cat test.cc
    enum BitFlags { BIT0, BIT1 };
    BitFlags operator|(BitFlags lhs, BitFlags rhs)
    return static_cast<BitFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs));
    int main(int, char**)
    BitFlags a = BIT0 | BIT1; // Error
    BitFlags b = BitFlags(BIT0 | BIT1); // OK, but operator|() not called
    BitFlags c = ::operator|(BIT0, BIT1); // OK (explicit operator call)
    return 0;
    $ CC test.cc
    "test.cc", line 11: Error: Cannot use int to initialize BitFlags.
    1 Error(s) detected.
    $ CC -V
    CC: Sun WorkShop 6 update 2 C++ 5.3 Patch 111685-07 2002/04/10
    Thanks in advance,
    Michael v. Szombathely

    This regression was not reproducible and works o.k. as of patch 11685-09. So, if you get the current patch 111685-14, this problem is fixed in that patch.

  • ABAP OO & Overloading

    Hi,
    I am trying to write a class in ABAP. And I need to overload my constructor. I have tried this overloading operation by SE80 transaction. But ABAP says "There is already a constructor". Is it not possible to overload a method/constructor in ABAP?
    Thanks.

    Hi,
    ABAP does not provide overloading of methods/constructors in a way we know from other OO languages (eg. Java). You cannot write a method with the same name but different signature. You can only override methods  in subclass using REDEFIITION key word but signature must stay the same.
    You can also provide a different constructor in sub class but the first statement in this constructor must be a call to constructor of super-class. But only one constructor can exist.
    Here is an example:
    *& Report  ZCL_OVR                                                     *
    REPORT  zcl_ovr                                                     .
    *       CLASS lcl_a DEFINITION
    CLASS lcl_a DEFINITION.
      PUBLIC SECTION.
        METHODS:
          constructor,
          do_sth IMPORTING iv_a TYPE i
                 RETURNING value(ov_b) TYPE i.
    ENDCLASS.                    "lcl_a DEFINITION
    *       CLASS lcl_a IMPLEMENTATION
    CLASS lcl_a IMPLEMENTATION.
      METHOD constructor.
      ENDMETHOD.                    "constructor
      METHOD do_sth.
        ov_b = 2 * iv_a.
      ENDMETHOD.                    "do_sth
    ENDCLASS.                    "lcl_a IMPLEMENTATION
    *       CLASS lcl_b DEFINITION
    CLASS lcl_b  DEFINITION INHERITING FROM lcl_a.
      PUBLIC SECTION.
        METHODS:
          constructor IMPORTING iv_a TYPE i,
          do_sth REDEFINITION.
      PRIVATE SECTION.
        DATA lv_c TYPE i.
    ENDCLASS.                    "lcl_b DEFINITION
    *       CLASS lcl_b IMPLEMENTATION
    CLASS lcl_b IMPLEMENTATION.
      METHOD constructor.
        CALL METHOD super->constructor.
        me->lv_c = iv_a.
      ENDMETHOD.                    "constructor
      METHOD do_sth.
        ov_b = 2 * iv_a + lv_c.
      ENDMETHOD.                    "do_sth
    ENDCLASS.                    "lcl_b IMPLEMENTATION

  • Differnce between LibCstd and LibStlport

    Hi
    what is the main difference if we Build application with LibCStd and LibStlport

    libCstd is potentially probably more standard-conforming than STLport
    In fact the Apache stdcxx is derived from the same roots - libCstd is just an older version of RogueWave Standard C++ Library
    All the seemingly missing parts are actually implemented in the headers but switched off by configuration macros setup in <tt>/opt/solstudio12.2/prod/include/CC/Cstd/stdcomp.h</tt>
    The configuration is by no means obtained from the automatic script (as suggested in the header itself) and it presents <tt>CC</tt> as an incapable old-fashioned pre-standard compiler (like from the times of SPARCWorks) that does not understand many advanced template features needed for implementating full standard by the library
    One has three choices to unlock standard features in libCstd:
    <ol>
    <li> Edit the <tt>CC/Cstd/stdcomp.h</tt> and make the following macros undefined (easier by commenting out their definitions)
    </li>
    <li> Create a file named <tt>stdcomp.h</tt>, fill it with properly edited contents and add the path using <tt>-I</tt> directive. This will cause the compiler to use created file instead of the original </li>
    <li> Create a file named <tt>stdcomp.h</tt> that will <tt>#include</tt> the original and adjust the macros. As with 2. include path needs to be provided with <tt>-I</tt>
    The fixed <tt>stdcomp.h</tt> header should look like:
    #ifndef _FIXED_STDCOMP_INCLUDED_
    #define _FIXED_STDCOMP_INCLUDED_
    // Include the original
    #include <Cstd/stdcomp.h>
    // Clear offending macros
    #undef _RWSTD_NO_MEMBER_TEMPLATES
    #undef RWSTD_NO_MEMBER_TEMPLATES
    #undef _RWSTD_NO_SIMPLE_DEFAULT_TEMPLATES
    #undef _RWSTD_NO_COMPLEX_DEFAULT_TEMPLATES
    #undef _RWSTD_NO_FRIEND_TEMPLATES
    #undef RWSTD_NO_FRIEND_TEMPLATES
    #undef _RWSTD_NO_MEM_CLASS_TEMPLATES
    #undef RWSTD_NO_MEM_CLASS_TEMPLATES
    #undef _RWSTD_NO_TEMPLATE_TEMPLATE
    #undef RWSTD_NO_TEMPLATE_TEMPLATE
    #undef _RWSTD_NO_EXPLICIT_ARG
    #undef RWSTD_NO_EXPLICIT_ARG
    #undef _RWSTD_NO_STATIC_MEM_DEF
    #undef RWSTD_NO_STATIC_MEM_DEF
    #undef _RWSTD_NO_DEFAULT_FOR_TPARAM
    #undef RWSTD_NO_DEFAULT_FOR_TPARAM
    #undef _RWSTD_NO_PART_SPEC_OVERLOAD
    #undef RWSTD_NO_PART_SPEC_OVERLOAD
    #undef _RWSTD_NO_INIT_CONST_TEMPLATE_REF_ARG
    #undef RWSTD_NO_INIT_CONST_TEMPLATE_REF_ARG
    #undef _RWSTD_NO_CLASS_PARTIAL_SPEC
    #undef RWSTD_NO_CLASS_PARTIAL_SPEC
    #undef _RWSTD_NO_FUNC_PARTIAL_SPEC
    #undef RWSTD_NO_FUNC_PARTIAL_SPEC
    #undef _RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
    #undef RWSTD_NO_TEMPLATE_ON_RETURN_TYPE
    // prevent the original from #define'ing the macros again
    #define RW_NEVER_ENTER_DEFAULT_HEADER_BLOCK 1
    // clear inclusion guard
    #undef __STD_RWCOMPILER_H__
    // include original once more
    #include <Cstd/stdcomp.h>
    // macro from stdcxx-4.x.x, used by vector<bool>
    #if defined(_RWSTD_ALLOCATOR) && !defined(_HPACC_)
    # define _RWSTD_REBIND(alloc, type) _TYPENAME alloc::template rebind<type>::other
    #else
    # define _RWSTD_REBIND(alloc, type) allocator_interface<alloc, type>
    #endif
    #endifDouble inclusion of original header is necessary because more macros will be defined after our #undefine's
    To prevent warnings about macros redefinition with second include more #undef's can be added, e.g. for <tt>RWSTDVER</tt>, <tt>RWSTD</tt> or <tt>__RWSTD</tt>
    The purpose of macro <tt>RWSTDREBIND</tt> will get clear in the following discussion. One may wish to add this definition if editing the original file in place.
    </li>
    </ol>
    No matter which solution is chosen there are a few other considerations:
    <ol>
    <li><tt>CC</tt> by default has implicit inclusion feature - it automatically includes files with template implementation during compilation. For a header <tt>name.extension</tt> it looks for files <tt>name.cc</tt> and <tt>name.cpp</tt> on include path and uses them without an explicit <tt>#include "name.cc"</tt>. This feature is used by <tt>libCstd</tt>, e.g. <tt><vector></tt> header includes <tt>vector.cc</tt> only if <tt>RWSTDCOMPILE_INSTANTIATE</tt> macro is defined (by default it is undefined).
    Though the feature is useful it may cause problems when a header named like one of the standard library is used (e.g. <tt><boost/container/vector.hpp></tt>). The compiler looks for an implementation file and uses the one from libCstd (<tt>CC/Cstd/vector.cc</tt> in this case). As the corresponding standard header has not been included it complains about defining methods for non-existing template class <tt>std::vector</tt>.
    If <tt>Boost.Container</tt> or other similar library is to be used one should add <tt>-template=no%extdef</tt> compiler option and define the macro <tt>RWSTDCOMPILE_INSTANTIATE</tt>.
    <li>Changes to <tt><stdcomp.h></tt> turns <tt>std::iterator_traits</tt> template on but the corresponding <tt>__iterator_category</tt> function specialization is missing. The best place for it is standard <tt><iterator></tt> header:
    #ifndef _ITERATOR_FIX_INCLUDED_
    #define _ITERATOR_FIX_INCLUDED_
    #include <Cstd/iterator>
    namespace _RW_STD {
    template<typename _IterT>
    inline typename iterator_traits<_IterT>::iterator_category
    __iterator_category(const _IterT&)
        return typename iterator_traits<_IterT>::iterator_category();
    #endif // _ITERATOR_FIX_INCLUDED_
    Note that the hacked file should be named <tt>iterator.SUNWCCh</tt> to be used by the compiler. CC does not include standard headers from files without that extension(of course one may edit <tt>CC/Cstd/iterator.SUNWCCh</tt> file directly)</li>
    <li>The changes unlock templatized constructor in <tt>std::pair</tt> class which can lead to ambiguity between overloads of <tt>insert</tt> methods of <tt>std::map</tt> container, namely
    pair<iterator, bool> insert(const value_type&);  // value_type is a typedef for pair<const key_type, mapped_type>
    pair<iterator, bool> insert(const pair<key_type, mapped_type>&);when called with an argument like <tt>std::make_pair(key, value)</tt> the compiler is not able to choose overload because the templatized <tt>pair</tt> constructor can convert between pairs that only differ in constantness of their components
    This time there is no <tt>#include</tt>-then-fix solution - one may edit the original <tt>CC/Cstd/map.SUNWCCh</tt> file or copy its contents to another location (again, remember about <tt>.SUNWCCh</tt> extension) and edit it there.
    The fix is to remove method
        pair<iterator, bool> insert (const pair<key_type, mapped_type> &__x)Best may be using conditional:
    #ifdef _RWSTD_NO_MEMBER_TEMPLATES
        pair<iterator, bool> insert (const pair<key_type, mapped_type> &__x)
    //... implementation
    #endifBe aware it is <tt>#ifdef</tt> here (not <tt>#ifndef</tt>) so the code gets excluded as <tt>RWSTDNO_MEMBER_TEMPLATES</tt> has been undefined
    </li>
    <li>With full partial template specialization support turned on we get into troubles with <tt>std::vector<bool></tt> class. The compiler complains that <tt>__first.p</tt> is inaccessible from <tt>vector<bool>::~vector()</tt> though <tt>vector<bool>::iterator</tt> contains friend class vector<bool, Allocator>;Changing that to friend class vector; fooled the compiler in full:
    >
    <tt>>> Assertion: (../lnk/ftemplate.cc, line 498)
    while processing libs/program_options/src/options_description.cpp at line 242</tt>
    >
    This looks like error in the compiler, in other contexts friend declarations in partially specialized classes work. When using <tt>CC</tt> compiler I found several times that a problematic code construct starts working in isolation.
    Returning to the <tt>std::vector<bool></tt> issue I found that putting the implementation from stdcxx 4.3.0 works. Thus one needs to edit (or copy and fix) <tt>CC/Cstd/vector.SUNWCCh</tt> and <tt>CC/Cstd/vector.cc</tt> files
    I provide here the changes for impatient, as this is not a direct copy-paste (some macros in 4.3.0 need changing to their 2.2.1 (i.e. libCstd) equivalents)
    In <tt>vector.SUNWCCh</tt> file replace vector<bool>specialization with
    #ifndef _RWSTD_NO_CLASS_PARTIAL_SPEC
    template <class _Allocator>
    class
    #else   // if defined (_RWSTD_NO_CLASS_PARTIAL_SPEC)
         // use a macro to mutate _Allocator into allocator<bool>
    # define _Allocator allocator<bool>
    _RWSTD_TEMPLATE
    class _RWSTDExport
    #endif  // _RWSTD_NO_CLASS_PARTIAL_SPEC
    vector<bool, _Allocator >: private _Allocator
        typedef _RWSTD_REBIND(_Allocator, unsigned int)       _C_value_alloc_type;
        typedef vector                                        _C_self;
    public:
        typedef _Allocator                                      allocator_type;
        typedef bool                                            value_type;
        typedef _TYPENAME allocator_type::size_type             size_type;
        typedef _TYPENAME allocator_type::difference_type       difference_type;
        typedef _TYPENAME _C_value_alloc_type::pointer          pointer;
        typedef _TYPENAME _C_value_alloc_type::const_pointer    const_pointer;
        class iterator;
        class const_iterator;
        class reference {
    #if !defined (__INTEL_COMPILER) || !defined (_MSC_VER)
            // avoid MSVC 6.0 bug 576
            friend class iterator;
    #else   // if Intel C++ 8.1 with MSVC
            // work around Intel C++ 8.1 bug 575
            friend class _C_self::iterator;
    #endif   // Intel C++ with MSVC
            friend class const_iterator;
        private:
            unsigned int* _C_p;
            unsigned int _C_mask;
            reference (unsigned int* __x, unsigned int __y)
                : _C_p (__x), _C_mask (__y) { }
        public:
            reference () : _C_p (), _C_mask () {}
            operator bool () const {
                return !!(*_C_p & _C_mask);
            reference& operator= (bool __x) {
                if (__x)     
                    *_C_p |= _C_mask;
                else
                    *_C_p &= ~_C_mask;
                return *this;
            reference& operator= (const reference& __x) {
                return *this = bool(__x);
    #ifndef _RWSTD_STRICT_ANSI
          bool operator== (const reference& __x) const {
              return bool(*this) == bool(__x);
          bool operator< (const reference& __x) const {
    #ifndef _MSC_VER
              return bool(*this) < bool(__x);
    #else
              return int(*this) < int(__x);
    #endif
            bool operator!= (const reference& __x) const {
                return !(*this == __x);
            bool operator> (const reference& __x) const {
                return  __x < *this;
            bool operator>= (const reference& __x) const {
                return !(*this < __x);
            bool operator<= (const reference& __x) const {
                return !(*this > __x);
    #endif // _RWSTD_STRICT_ANSI
            void flip () {
                *_C_p ^= _C_mask;
        typedef bool const_reference;
        // hacks working around bogus g++ 2.95.2 warnings coming out of
        // iterators below as well as what's probably an MSVC 6.0 bug
        typedef reference       _C_ref;
        typedef const_reference _C_const_ref;
        typedef difference_type _C_diff_t;
        class _C_iter {
            friend class iterator;
            friend class const_iterator;
        private:
    #if defined (__GNUG__)
            // gcc 3.0.1 and prior take 14.5.3, p9 literally
        public:
    #elif    defined (_MSC_VER) && _MSC_VER <= 1300 || defined (__APOGEE__)
            friend class vector<bool, _Allocator>;
    #else
            friend class vector;
    #endif
            unsigned int* _C_p;        // pointer to the current word
            unsigned int  _C_offset;   // number of the pointed-to bit
            _C_iter (unsigned int* __x = 0, unsigned int __y = 0)
                : _C_p (__x), _C_offset (__y) { }
            // On Sun, gcc 3.1 does generate an incorrect copy constructor
            // that has as an effect an incompletely/incorrectly initialized
            // iterator.
    #if    defined (__sun__) && defined (__GNUG__) \
        || defined (__SUNPRO_CC) && defined (__amd64__)
            // working around a gcc 3.1 bug on Solaris where the compiler
            // generates bad code for the implicitly defined copy ctor
            // also working around a Sun C++ 5.9 optimizer ICE on x86_64
            // in wide (64-bit) mode (see STDCXX-551)
            _C_iter (const _C_iter& __it)
                : _C_p (__it._C_p), _C_offset (__it._C_offset) {}
    #endif   // gcc 3.1/Solaris || Sun C++ 5.9/x86_64
            void operator++ () {
                if (_C_offset++ == _RWSTD_WORD_BIT - 1) {
                    _C_offset = 0;
                    ++_C_p;
            void operator-- () {
                if (_C_offset-- == 0) {
                    _C_offset = _RWSTD_WORD_BIT - 1;
                    --_C_p;
            void operator+= (difference_type __i) {
                difference_type __n = __i + _C_offset;
                _C_p += __n / _RWSTD_WORD_BIT;
                __n = __n % _RWSTD_WORD_BIT;
                if (__n < 0) {
                    _C_offset = _RWSTD_STATIC_CAST (unsigned int,
                                                    __n + _RWSTD_WORD_BIT);
                    --_C_p;
                else
                    _C_offset = _RWSTD_STATIC_CAST (unsigned int,__n);
        public:
            bool operator== (const _C_iter& __x) const {
                return _C_p == __x._C_p && _C_offset == __x._C_offset;
            bool operator< (const _C_iter& __x) const {
                return _C_p < __x._C_p ||
                    (_C_p == __x._C_p && _C_offset < __x._C_offset);
            bool operator!= (const _C_iter& __x) const {
                return !(*this == __x);
            bool operator> (const _C_iter& __x) const {
                return __x < *this;
            bool operator>= (const _C_iter& __x) const {
                return !(*this < __x);
            bool operator<= (const _C_iter& __x) const {
                return !(*this > __x);
        class iterator
            : public _C_iter,
              public _RW_STD::iterator<random_access_iterator_tag,
                                       value_type, _C_diff_t,
                                       pointer, _C_ref> {
        public:
            // bring names used in declarations below into scope
            // (dependent base members not visible without qualification)
            typedef _C_ref    reference;
            typedef _C_diff_t difference_type;
            iterator (unsigned int *__x = 0, unsigned int __y = 0)
                : _C_iter (__x, __y) { }
            reference operator* () const {
                return reference (this->_C_p, 1U << this->_C_offset);
            iterator& operator++ () {
                return _C_iter::operator++(), *this;
            iterator operator++ (int) {
                iterator __tmp = *this;
                ++*this;
                return __tmp;
            iterator& operator-- () {
                return _C_iter::operator--(), *this;
            iterator operator-- (int) {
                iterator __tmp = *this;
                --*this;
                return __tmp;
            iterator& operator+= (difference_type __i) {
                return _C_iter::operator+= (__i), *this;
            iterator& operator-= (difference_type __i) {
                *this += -__i;
                return *this;
            iterator operator+ (difference_type __i) const {
                iterator __tmp = *this;
                return __tmp += __i;
            iterator operator- (difference_type __i) const {
                iterator __tmp = *this;
                return __tmp -= __i;
            difference_type operator- (iterator __x) const {
                return   _RWSTD_WORD_BIT * (this->_C_p - __x._C_p)
                       + this->_C_offset - __x._C_offset;
            reference operator[] (difference_type __i) {
                return *(*this + __i);
            friend iterator operator+ (difference_type __i,
                                       const iterator &__x) {
                return __x + __i;
        class const_iterator
            : public _C_iter,
              public _RW_STD::iterator<random_access_iterator_tag,
                                       value_type, _C_diff_t,
                                       const_pointer, _C_const_ref> {
        public:
            // bring names used in declarations below into scope
            // (dependent base members not visible without qualification)
            typedef _C_const_ref const_reference;
            typedef _C_diff_t    difference_type;
            const_iterator (unsigned int *__x = 0, unsigned int __y = 0)
                : _C_iter (__x, __y) { }
            const_iterator (const _C_iter &__x)
                : _C_iter (__x) { }
            const_reference operator* () const {
                return _C_ref (this->_C_p, 1U << this->_C_offset);
            const_iterator& operator++ () {
                return _C_iter::operator++(), *this;
            const_iterator operator++ (int) {
                const_iterator __tmp = *this;
                ++*this;
                return __tmp;
            const_iterator& operator-- () {
                return _C_iter::operator--(), *this;
            const_iterator operator-- (int) {
                const_iterator __tmp = *this;
                --*this;
                return __tmp;
            const_iterator& operator+= (difference_type __i) {
                return _C_iter::operator+= (__i), *this;
            const_iterator& operator-= (difference_type __i) {
                return *this += -__i;
            const_iterator
            operator+ (difference_type __i) const {
                return const_iterator (*this) += __i;
            const_iterator operator- (difference_type __i) const {
                return const_iterator (*this) -= __i;
            difference_type operator- (const_iterator __x) const {
                return   _RWSTD_WORD_BIT * (this->_C_p - __x._C_p)
                       + this->_C_offset - __x._C_offset;
            const_reference operator[] (difference_type __i) {
                return *(*this + __i);
            friend const_iterator operator+ (difference_type __i,
                                             const const_iterator &__x) {
                return __x + __i;
    #ifndef _RWSTD_NO_CLASS_PARTIAL_SPEC
        typedef _RW_STD::reverse_iterator<const_iterator> const_reverse_iterator;
        typedef _RW_STD::reverse_iterator<iterator>       reverse_iterator;
    #else
        typedef _RW_STD::reverse_iterator<const_iterator,
            random_access_iterator_tag, value_type,
            const_reference, const_pointer, difference_type>
        const_reverse_iterator;
        typedef _RW_STD::reverse_iterator<iterator,
            random_access_iterator_tag, value_type,
            reference, pointer, difference_type>
        reverse_iterator;
    #endif   // _RWSTD_NO_CLASS_PARTIAL_SPEC
      private:
        // These private functions are replicas of generic algorithms.
        //  We provide them here to avoid putting instantiations of
        //  the generic algorithms into an archive or shared library.
        //  This gives you full flexibilty in deciding where you want
        //  to put particular instantiations of the generic
        //  algorithms.
        void _C_fill (iterator __first, iterator __last, bool __val) {
            while (__first != __last) *__first++ = __val;
        void _C_fill_n (iterator __first, size_type __n, bool __val) {
            while (__n-- > 0) *__first++ = __val;
        template <class _Iterator>
        iterator _C_copy (_Iterator __first, _Iterator __last, iterator __res) {
            while (__first != __last)
                *__res++ = *__first++;
            return __res;
        template <class _Iterator>
        iterator
        _C_copy_backward (_Iterator __first, _Iterator __last, iterator __res) {
            while (__first != __last) *--__res = *--__last;
            return __res;
    private:
        iterator       _C_begin;
        iterator       _C_end;
        unsigned int * _C_bufend;
        unsigned int* _C_bit_alloc (size_type __n) {
            return _C_value_alloc_type(*this).
                allocate ((__n + _RWSTD_WORD_BIT - 1)/_RWSTD_WORD_BIT,
                          pointer(_C_begin._C_p));
        void _C_init (size_type __n) {
            unsigned int* __q = _C_bit_alloc(__n);
            _C_bufend = __q + (__n + _RWSTD_WORD_BIT - 1)/_RWSTD_WORD_BIT;
            _C_begin  = iterator(__q, 0);
            _C_end    = _C_begin + __n;
        void _C_insert (iterator, bool);
    public:
        vector (const _Allocator&  __alloc = allocator_type ())
            : allocator_type (__alloc), _C_begin(iterator()), _C_end(iterator()),
            _C_bufend () { }
    #if !defined (__SUNPRO_CC) || __SUNPRO_CC > 0x530
        // working around a SunPro 5.3 bug (see PR #25962)
        explicit
    #endif   // SunPro > 5.3
        vector (size_type __n, bool __val = bool (),
           const _Allocator&  __alloc = allocator_type ())
            : allocator_type (__alloc), _C_bufend () {
          _C_init(__n);
          unsigned int * __first = _C_begin._C_p;
          size_type __m = (__n + _RWSTD_WORD_BIT - 1)/_RWSTD_WORD_BIT;
          while (__m-- > 0) *__first++ = __val ? ~0 : 0;
        vector (const _C_self &__x)
            : allocator_type (__x.get_allocator ()), _C_bufend  () {
            _C_init (__x.size ());
            _C_copy (__x.begin (), __x.end (), _C_begin);
        template<class _InputIter>
        vector  (_InputIter __first, _InputIter __last)
            : allocator_type (), _C_bufend ()
          size_type __n;
          distance(__first, __last, n);
          _C_init(__n);
          _C_copy(__first, __last, _C_begin);
        ~vector () {
          _C_value_alloc_type(*this).deallocate(_C_begin._C_p, 
            _C_bufend - _C_begin._C_p);
        _C_self& operator= (const _C_self& __x)
          if (&__x == this) return *this;
          if (__x.size() > capacity())
            _C_value_alloc_type(*this).deallocate(_C_begin._C_p,
              _C_bufend - _C_begin._C_p);
            _C_init(__x.size());
          _C_copy(__x.begin(), __x.end(), begin());
          _C_end = begin() + __x.size();
          return *this;
        template<class _InputIter>
        void assign (_InputIter __first, _InputIter __last) {
            clear ();
            insert (begin (), __first, __last);
        void assign (size_type __n, const bool& __x = bool()) {
            clear ();
            insert (begin (), __n, __x);
        allocator_type get_allocator() const {
          return *this;
        // iterators
        iterator       begin ()       { return _C_begin; }
        const_iterator begin () const
        { return const_iterator(_C_begin._C_p,_C_begin._C_offset); }
        iterator       end   ()       { return _C_end; }
        const_iterator end   () const
        { return const_iterator(_C_end._C_p,_C_end._C_offset); }
        reverse_iterator       rbegin () { return reverse_iterator(end()); }
        const_reverse_iterator rbegin () const
          return const_reverse_iterator(end());
        reverse_iterator       rend () { return reverse_iterator(begin()); }
        const_reverse_iterator rend () const
          return const_reverse_iterator(begin());
        // capacity
        size_type size     () const { return size_type(end() - begin());  }
        size_type max_size () const {
            return _C_value_alloc_type(*this).max_size();
        void resize (size_type __new_size, bool __c = false);
        size_type capacity () const
          return size_type(const_iterator(_C_bufend, 0) - begin());
        bool empty () const { return begin() == end(); }
        void reserve (size_type __n)
            _RWSTD_THROW(__n > max_size(), length_error,
              __RWSTD::except_msg_string(__RWSTD::__rwse_InvalidSizeParam,
                "vector<bool>::reserve(size_type)",__n,max_size()).msgstr());
          if (capacity() < __n)
            unsigned int* __q = _C_bit_alloc(__n);
            _C_end = _C_copy(begin(), end(), iterator(__q, 0));
            _C_value_alloc_type(*this).deallocate(_C_begin._C_p,
                                                 _C_bufend - _C_begin._C_p);
            _C_begin = iterator(__q, 0);
            _C_bufend = __q + (__n + _RWSTD_WORD_BIT - 1)/_RWSTD_WORD_BIT;
        // element access
        reference       operator[] (size_type __n)      
    #ifdef _RWSTD_BOUNDS_CHECKING
            _RWSTD_THROW(__n >= size(), out_of_range,
              __RWSTD::except_msg_string(__RWSTD::rwse_OutOfRange,
                "vector<bool>::[](size_type)", __n, size()).msgstr());
    #endif   // _RWSTD_BOUNDS_CHECKING
          return *(begin() + __n);
        const_reference operator[] (size_type __n) const
    #ifdef _RWSTD_BOUNDS_CHECKING
            _RWSTD_THROW(__n >= size(), out_of_range,
              __RWSTD::except_msg_string(__RWSTD::rwse_OutOfRange,
                "vector<bool>::[](size_type) const", __n, size()).msgstr());
    #endif   // _RWSTD_BOUNDS_CHECKING
          return *(begin() + __n);
        reference       at (size_type __n)              
            _RWSTD_THROW(__n >= size(), out_of_range,
              __RWSTD::except_msg_string(__RWSTD::rwse_OutOfRange,
                "vector<bool>::at(size_type)", __n, size ()).msgstr());
          return *(begin() + __n);
        const_reference at (size_type __n) const
            _RWSTD_THROW(__n >= size(), out_of_range,
              __RWSTD::except_msg_string(__RWSTD::rwse_OutOfRange,
                "vector<bool>::at(size_type) const", __n, size()).msgstr());
          return *(begin() + __n);
        reference       front ()       { return *begin();     }
        const_reference front () const { return *begin();     }
        reference       back  ()       { return *(end() - 1); }
        const_reference back  () const { return *(end() - 1); }
        // modifiers
        void push_back (const bool& __x)
            if (_C_end._C_p != _C_bufend) {
                ++_C_end;
                *(_C_end-1) = __x;
            else
                _C_insert(end(), __x);
        void pop_back () { --_C_end; }
        iterator insert (iterator __it, const bool& __x = bool())
          size_type __n = __it - begin();
          if (_C_end._C_p != _C_bufend && __it == end()) {
              ++_C_end;
              *(_C_end-1) = __x;
          else
            _C_insert(__it, __x);
          return begin() + __n;
        void insert (iterator __it, size_type __n, const bool& __x);
        template<class _InputIter>
        void insert (iterator __it, _InputIter __first,
                     _InputIter __last);
        iterator erase (iterator __it)
          if (!(__it + 1 == end()))
            _C_copy(__it + 1, end(), __it);
          --_C_end;
          return __it;
        iterator erase(iterator __first, iterator __last)
          _C_end = _C_copy(__last, end(), __first);
          return __first;
        void swap (_C_self& __x)
          if((_C_value_alloc_type)*this == (_C_value_alloc_type)__x)
            _STD::swap (_C_begin,  __x._C_begin);
            _STD::swap (_C_end,    __x._C_end);
            _STD::swap (_C_bufend, __x._C_bufend);
          else
            _C_self _x = *this;
            *this = __x;
            __x=_x;
        static void swap(reference __x, reference __y);
        void flip ();
        void clear()
          erase(begin(),end());
    #if defined (_RWSTD_NO_PART_SPEC_OVERLOAD)
        friend void swap (vector& __lhs, vector& __rhs) {
            __lhs.swap (__rhs);
    #endif
    #undef _Allocatorto be continued in the next post, whole text exceeds 30k characters :)

  • Jdeveloper 11g - JAX-RPC 1.1 method is not supported in WLS 8.1 clients.

    Hi,
    I am using Jdeveloper 11g and migrating a web Service Proxy created using jdeveloper 10g.
    I imported all the proxy classes and when I try to run web service client In Jdeveloper 11g I get the following error
    "JAX-RPC 1.1 method is not supported in WLS 8.1 clients. If you are attempting to run an OC4J 10.1.3 JAX-RPC client in WLS, please see the Web Service Migration Guide for instructions."
    Please advise on how to solve this?
    which is the offending jar/library file in Jdeveloper 11g which is causing the above error?.
    Is the above problem there in the WebLogic Server Runtime also?
    Please let me know.
    2) I cannot generate web server proxies also with jdev11g because the wsdl has overloaded methods omitting the name property within the input and output message, ie, they have a null name. therefore Jdeveloper 11g is using the library which
    when called with an overloaded operation that contains null input/output message names, a duplicate error occurs because it sees other operations with the same name. so it is effectively not allowing to create the web service proxies.
    Thanks,
    Appreciate your quick response to the above

    Have you checked the 'Web Service Migration Guide' mentioned in the error message?
    Timo

  • Concat a newline to the  string

    I want to concatinate a new line to the existing string and then concatinate some other string.
    My question is what should i use to concatinate a new line

    No doubt, Thomas.
    You might want to read this:
    http://wiki.java.net/bin/view/Javapedia/AlwaysUseString
    ufferMisconception
    MODWell, maybe you should read that article one more time and more carefully yourself.
    I was concatenating three Strings, only one of those is literal String. ;-)
    My post was not intended to correct the previous answers in their use of string concatenation, I was too slow in typing to be the first on to answer. :-(
    On the other hand, it's true that I don't like using the overloaded + operator - it's a pure style thingie to me with the beneficial side effect of a performance increase in large loops ... anyways I never understood why Java would disallow operator overloading but then being inconsistent when it came to Strings.

  • Adding 2 objects together

    how would i add to objects together if a condition is true? (using polymorphism)
    for example we have 2 objects already created and has a certain job (both different)
    when a new employee comes in the company - they may have the same job of any of the existing employees and therefore is assigned to the existing employee
    would i have to create a seperate class and a relationship?
    what do i do?
    thanks :)

    How I long for something like this in Java (not the
    best example, of course)
    //=== Employee.h file =============================
    Employee operator+(Employee e) const;
    //=== Employee.cc file ===========================
    Employee Employee::operator+(Employee e) const
    return new Employee(e.hireDate, e.title);
    Why? you have overloaded the + operator, which has been associated for hundreds if not thousands of years with the semantics of addition, for an object of type Employee to return a new employee which has the same hire date and title as the second argument of the operator.
    Firstly, + is a binary, associative,commutative operator, and your method doesn't support any of these properties.
    You don't make any reference to the first argument: a + b will result in an employee with the same hire date and title as b irrespective of whatever a may be. So your version of + is not implementing a binary function.
    Secondly, and as a byproduct, a + b != b + a, so it's not commutative.
    Though it is associative (a + b) + c == a + (b + c), but that largely if because x + c = c for all x (assuming == overloaded to only compare the hire date and title).
    Furthermore, it is unlikely than a * 5 == a + a + a + a + a, so employee only support part of a set of related operators.
    (the overloaded + operator for String in Java also fails in this regard; in fact, (as it wouldn't alter the determinacy of the parser) the operator is redundant- the language could as easily have been designed to concatenate adjacent strings, or adjacent strings and other expressions, or use another operator. It also would be nice if "hi"*5 evaluated to "hihihihihi".)
    Whilst I would like to have operator overloading for writing certain code, such as matrices, as a convenience, when presented with examples like the above I can quite understand why the Java language team are against providing it in Java.
    Pete

  • Integer to string

    Hi , I declare a variable int i = 001, i++ etc... than i want to use "i" in a string like "..." + i + " ...." , but the problem that I am loosing the zeros
    ( i become 1 instead of 001 ), any help ? tks

    I think, If u declare it as integer it would not be possible.
    But if you want some thing what you have told you can implement your own number class and operations on dat.
    Put 001 in an array a= [0,0,1] and manpulate the array to have desired operations
    Note: There is no overloading operator in java. So you cannot do i++ and all.so u can replace them like postincrement(i)
    Thanks
    D. L. Kumar

  • Overriding = in my AnyType class

    I am trying to create an AnyType class. I am wondering if it is possible to override the = operator like you can in C++. The AnyType class will be used in a method (setValue(AnyType type, String path)) to accept any type that is passed to it. Based on what is passed in the setValue method will be doing different things. It seems easier to handle it with a single method that will accept any type as opposed to overloading the setValue method multiple times. I am also working on using the AnyType as a return from some methods. Any suggestions? Is this possible??
    Thanks,
    Jim Pagnotta

    Hi JIM,
    As in C++ no operator overloading is possible in Java. So you cannt overload = operator . and as far as i know in c++ also you cant overide = opertor .i think you are talking about overridding == operator.
    My suggestion to this, is accept an instance of Object class as one of the parameters of your setValue() method and use instance of operator to find out the class of it and work accordingly.

  • IDE suddenly gets out of sync with dbx

    I recently have seen a few cases where, during debugging sesions, the IDE gets out of sync with dbx: while sitting at a breakpoint, the debugger toolbar buttons suddenly are greyed out with the exception of the "Pause" button, as if the inferior process were running. A message "Process state modified" is displayed briefly in the status line at the bottom. I suspect this may be due to a problem with balloon evaluation, because somehow it seems to be triggered by cursor motion.
    It is possible to "rectify" the situation by issueing a "next" in the dbx console, after this, the debugger toolbar buttons revert to their normal state.
    I will try to narrow this down further. Is there anything I can do which could help to find the problem?
    This happened with Sunstudio Express 07/08 as well as with 11/08.

    I finally managed to reproduce this reliably. This was confusing at first because it does not only involve certain C++ code, but also the dbxenv variable output_dynamic_type.
    This is indeed a balloon evaluation issue: If the mouse pointer hovers over an expression which involves an overloaded "operator->()", I usually get a balloon saying "<contains function calls>, which is okay. If I set "dbxenv output_dynamic_type on", I get the same output, but the toolbar switches somehow to "running" when the balloon pops up.
    I can reproduce this with just a dozen lines of self-contained C++ code.
    I will report a bug at bugs.sun.com.
    BTW: could anybody please set the timeout value for posts and replies in this forum to a reasonable value? This reply took me only a few minutes, but when i actually posted the message I got a timeout response...

Maybe you are looking for

  • How to use  SET and GET parameter commands ?

    Explain these two giving an example?As which is used for what?

  • Creating a form using Acrobat 9

    I'm trying to create a form using Acrobat 9 and know how to insert check boxes and text fields but when I enter in data into the fields it copies it through the document.  How can I create a field that I can cut and paste throughout the document but

  • Gmail will not display in a usable format

    when accessed from Firefox my gmail account does not display or allow all navigational functions

  • Opening Garage Band file in other applications

    I am a film director whose scorer composed the soundtrack in Garage Band 3. I cannot open it in GB 2.0.2? Do I need to pay for an update or can I open it in Final Cut Pro or Soundtrack Pro? I want to be able to manipulate some of the instrumentation

  • 5.1 sound on Envy 17t 3200 3D?

    Before ordering an HP agent said the unit would support 5.1 sound using my existing speakers with 3.5mm mini-plugs for front, center/sub and rear channels.  Now that I have the unit I see only 2 audio in 3.5mm jacks and the driver does not have a 5.1