This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

some std::vector's internals declared as public


Hello,

JFYI:

It looks that some of the std::vector internal methods (prefixed '_M_')
are declared as public within the libstdc++ shipped with gcc-3.1 and
gcc-3.1.1 (gcc-3.1.1 has unchanged stl_vector.h).
The priority is low, since it's very unlikely anybody will use them.

An auxiliary function was needed for dk_std::vector stuff,
called _M_after_erase_capacity_fix. While looking at the source to find
how the internal methods are declared, some of them were found public.
For example, this gets compiled:

$ cat vector_test.cpp 
#include <vector> //for std::vector

int main(int argc, char *argv[])
{
        std::vector<int> a;
        a._M_range_check(123);
        return 0;
}
$ make vector_test     
g++     vector_test.cpp   -o vector_test
$ ./vector_test ;echo $?
Abort (core dumped)
134
$ 

Some time was spent to find other such methods, there is a list at the
end (perhaps complete). Will it help you, when I prepare a patch?

It's not a problem at all to forget 'protected:' in a source file 
as long as stl_vector.h is.
Personally I'm using the following to get over long headers:

- no method defined in a header, no matter how simple it is.
  (this keeps headers shorter, easier to follow)
- all definitions in a source file, every method can be easily found
  by searching the pattern ^method_name(
- _funny_ macros to handle inlining and templates

I don't know, maybe there is a number of better ways
(not seeking them, for now I can stand the above).

The list mentioned:

void _M_range_check(size_type) const;

template <class _Integer>
void _M_initialize_aux(_Integer, _Integer, __true_type);

template<class _InputIterator>
void _M_initialize_aux(_InputIterator, _InputIterator, __false_type);

void _M_fill_assign(size_type, const _Tp&);

template<class _Integer>
void _M_assign_dispatch(_Integer, _Integer, __true_type);

template<class _InputIter>
void _M_assign_dispatch(_InputIter, _InputIter, __false_type);

template <class _InputIterator>
void _M_assign_aux(_InputIterator, _InputIterator, input_iterator_tag);

template <class _ForwardIterator>
void _M_assign_aux(_ForwardIterator, _ForwardIterator, forward_iterator_tag);

template <class _Integer>
void _M_insert_dispatch(iterator, _Integer, _Integer, __true_type);

template<class _InputIterator>
void _M_insert_dispatch(iterator, _InputIterator, _InputIterator, __false_type);

void _M_fill_insert(iterator, size_type, const _Tp&);

Well, take it easy.

Regards,

Daniel

-- 
Daniel Kostecky, dk at kotelna dot sk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]