Compare boost::hana to D

Kagamin via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 19 04:58:07 PDT 2017


On Wednesday, 19 April 2017 at 09:01:25 UTC, Sebastiaan Koppe 
wrote:
> Haven't used C++ for a while actually. And seeing it after some 
> time, makes me tremble convulsively.

_STD_BEGIN
         // basic_string INSERTERS AND EXTRACTORS
template<class _Elem,
     class _Traits,
     class _Alloc> inline
     basic_istream<_Elem, _Traits>& operator>>(
         basic_istream<_Elem, _Traits>&& _Istr,
         basic_string<_Elem, _Traits, _Alloc>& _Str)
     {	// extract a string
     typedef ctype<_Elem> _Ctype;
     typedef basic_istream<_Elem, _Traits> _Myis;
     typedef basic_string<_Elem, _Traits, _Alloc> _Mystr;
     typedef typename _Mystr::size_type _Mysizt;

     ios_base::iostate _State = ios_base::goodbit;
     bool _Changed = false;
     const typename _Myis::sentry _Ok(_Istr);

     if (_Ok)
         {	// state okay, extract characters
         const _Ctype& _Ctype_fac = _USE(_Istr.getloc(), _Ctype);
         _Str.erase();

         _TRY_IO_BEGIN
         _Mysizt _Size = 0 < _Istr.width()
             && (_Mysizt)_Istr.width() < _Str.max_size()
                 ? (_Mysizt)_Istr.width() : _Str.max_size();
         typename _Traits::int_type _Meta = _Istr.rdbuf()->sgetc();

         for (; 0 < _Size; --_Size, _Meta = 
_Istr.rdbuf()->snextc())
             if(_Traits::eq_int_type(_Traits::eof(), _Meta))
                 {	// end of file, quit
                 _State |= ios_base::eofbit;
                 break;
                 }
             else if (_Ctype_fac.is(_Ctype::space,
                 _Traits::to_char_type(_Meta)))
                 break;	// whitespace, quit
             else
                 {	// add character to string
                 _Str.append(1, _Traits::to_char_type(_Meta));
                 _Changed = true;
                 }
         _CATCH_IO_(_Istr)
         }

     _Istr.width(0);
     if (!_Changed)
         _State |= ios_base::failbit;
     _Istr.setstate(_State);
     return (_Istr);
     }

:)


More information about the Digitalmars-d mailing list