I am currently validating my c++ parser but i failed to parse c++ header which is cygwin, the file is named "C:\cygwin\lib\gcc\i686-pc-cygwin\3.4.4\include\c++\bits/basic_string.tcc"
in that file there is declaration of assign template function:
My problem is :Code:
template <class _Arg1, class _Arg2, class _Result>
struct binary_function
{
typedef _Arg1 first_argument_type; ///< the type of the first argument
/// (no surprises here)
typedef _Arg2 second_argument_type; ///< the type of the second argument
typedef _Result result_type; ///< type of the return type
};
template <class _Tp>
struct less : public binary_function<_Tp, _Tp, bool>
{
bool
operator()(const _Tp& __x, const _Tp& __y) const
{ return __x < __y; }
};
template<typename _CharT, typename _Traits, typename _Alloc>
basic_string<_CharT, _Traits, _Alloc>&
basic_string<_CharT, _Traits, _Alloc>::
assign(const _CharT* __s, size_type __n)
{
__glibcxx_requires_string_len(__s, __n);
if (__n > this->max_size())
__throw_length_error(__N("basic_string::assign"));
if (_M_rep()->_M_is_shared() || less<const _CharT*>()(__s, _M_data())
|| less<const _CharT*>()(_M_data() + this->size(), __s))
return _M_replace_safe(size_type(0), this->size(), __s, __n);
else
{
// Work in-place
const size_type __pos = __s - _M_data();
if (__pos >= __n)
traits_type::copy(_M_data(), __s, __n);
else if (__pos)
traits_type::move(_M_data(), __s, __n);
_M_rep()->_M_set_sharable();
_M_rep()->_M_length = __n;
_M_data()[__n] = _Rep::_S_terminal; // grr.
return *this;
}
}
less<const _CharT*>()(__s, _M_data())
Which i really don't understand, seems like this call explicitly the () operator but I cant find in the c++ iso grammar what are the rule used. Is that code use some gcc extension ?
any help would be greatly appreciated.