Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > string's class question

Reply
Thread Tools

string's class question

 
 
Nephi Immortal
Guest
Posts: n/a
 
      09-09-2011
I was curious to examine Microsoft’s source code. The headers are
string, xmemory, and xutility. I could see container class and proxy
class. They inherit into _String_val and _String_val inherits into
basic_string.
Why are several classes needed? Why not create single basic_string
class? Look at Microsoft’s code here.

struct _Container_base12;
struct _Iterator_base12;

// CLASS _Container_proxy
struct _Container_proxy
{ // store head of iterator chain and back pointer
_Container_proxy()
: _Mycont(0), _Myfirstiter(0)
{ // construct from pointers
}

const _Container_base12 *_Mycont;
_Iterator_base12 *_Myfirstiter;
};

struct _CRTIMP2_PURE _Container_base12
{ // store pointer to _Container_proxy
public:
_Container_base12()
: _Myproxy(0)
{ // construct childless container
}

_Container_base12(const _Container_base12&)
: _Myproxy(0)
{ // copy a container
}

_Container_base12& operator=(const _Container_base12&)
{ // assign a container
return (*this);
}

~_Container_base12()
{ // destroy the container
_Orphan_all();
}

_Iterator_base12 **_Getpfirst() const
{ // get address of iterator chain
return (_Myproxy == 0 ? 0 : &_Myproxy->_Myfirstiter);
}

void _Orphan_all(); // orphan all iterators
void _Swap_all(_Container_base12&); // swap all iterators

_Container_proxy *_Myproxy;
};
 
Reply With Quote
 
 
 
 
Bo Persson
Guest
Posts: n/a
 
      09-10-2011
Nephi Immortal wrote:
> I was curious to examine Microsoft’s source code. The headers are
> string, xmemory, and xutility. I could see container class and
> proxy class. They inherit into _String_val and _String_val
> inherits into basic_string.
> Why are several classes needed? Why not create single basic_string
> class? Look at Microsoft’s code here.
>
> struct _Container_base12;
> struct _Iterator_base12;
>
> // CLASS _Container_proxy
> struct _Container_proxy
> { // store head of iterator chain and back pointer
> _Container_proxy()
>> _Mycont(0), _Myfirstiter(0)

> { // construct from pointers
> }
>
> const _Container_base12 *_Mycont;
> _Iterator_base12 *_Myfirstiter;
> };
>
>


That looks like code used for iterator debugging in debug mode.
Putting it in a base class perhaps help sharing this code with other
containers?

Anyway, this is just an implementation detail that doesn't matter
much. A library is allowed to organize the code the way it wants to.


Bo Persson


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Class A contains class B, class B points to class A Joseph Turian C++ 5 12-30-2005 03:24 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
A parameterized class (i.e. template class / class template) is not a class? christopher diggins C++ 16 05-04-2005 12:26 AM
Generic class literals - e.g,, Class<Map<String, Integer>>.class Purush Java 4 04-13-2005 08:40 PM
instanciate a class in a jar file with class.forname, while my main class is in another jar cyril Java 2 08-25-2004 06:55 AM



Advertisments