Daniel Kostecky - some std::vector's internals declared as public (original) (raw)
This is the mail archive of the libstdc++@gcc.gnu.orgmailing 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] |
- From: Daniel Kostecky
- To: GCC std C++ library discussion <libstdc++ at gcc dot gnu dot org>
- Date: Mon, 5 Aug 2002 15:08:51 +0200
- Subject: some std::vector's internals declared as public
- Reply-to: Daniel Kostecky
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 //for std::vector
int main(int argc, char *argv[])
{
std::vector 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 void _M_initialize_aux(_Integer, _Integer, __true_type);
template void _M_initialize_aux(_InputIterator, _InputIterator, __false_type);
void _M_fill_assign(size_type, const _Tp&);
template void _M_assign_dispatch(_Integer, _Integer, __true_type);
template void _M_assign_dispatch(_InputIter, _InputIter, __false_type);
template void _M_assign_aux(_InputIterator, _InputIterator, input_iterator_tag);
template void _M_assign_aux(_ForwardIterator, _ForwardIterator, forward_iterator_tag);
template void _M_insert_dispatch(iterator, _Integer, _Integer, __true_type);
template 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
- Follow-Ups:
- Re: some std::vector's internals declared as public
* From: Phil Edwards
- Re: some std::vector's internals declared as public
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |