Deprecated: Function create_function() is deprecated in /var/www/blog/inc/libs/clearbricks/common/lib.l10n.php on line 640

Deprecated: Function create_function() is deprecated in /var/www/blog/inc/libs/clearbricks/common/lib.http.php on line 249
C++ Streams suck - Grumpycoder
Flux RSS

C++ Streams suck


This one is a short one (and actually, more an excuse to test highlight.js), but C++ Streams really, really suck. You can say whatever you want, they are the spawn of the devil. Case in point:
#include <iostream>
#include <iomanip>

void hexDump(
    const unsigned char * data,
    size_t size,
    std::ostream & str)
{
    size_t addr = 0;
    str << std::hex
        << std::setfill('0')
        << std::nouppercase
        << std::noshowbase;
    while (addr < size) {
        str << std::setw(8)
            << addr
            << ":   ";
        for (int i = 0; i < 16 && addr < size; i++) {
            str << std::setw(2)
                << static_cast<unsigned int>(data[addr++])
                << " ";
        }
        str << std::endl;
    }
    str << std::resetiosflags;
}

Fatal error: Uncaught Error: [] operator not supported for strings in /var/www/blog/inc/core/class.dc.postmedia.php:61 Stack trace: #0 /var/www/blog/inc/core/class.dc.media.php(592): dcPostMedia->getPostMedia(Array) #1 /var/www/blog/cache/cbtpl/29/59/2959320ca61719bec433f91e69098e86.php(137): dcMedia->getPostMedia('36', NULL, 'attachment') #2 /var/www/blog/inc/libs/clearbricks/template/class.template.php(268): include('/var/www/blog/c...') #3 /var/www/blog/inc/public/class.dc.template.php(231): template->getData('post.html') #4 /var/www/blog/inc/public/lib.urlhandlers.php(122): dcTemplate->getData('post.html') #5 /var/www/blog/inc/public/lib.urlhandlers.php(523): dcUrlHandlers::serveDocument('post.html') #6 /var/www/blog/inc/libs/clearbricks/url.handler/class.url.handler.php(166): dcUrlHandlers::post('2013/01/20/C-St...') #7 /var/www/blog/inc/public/lib.urlhandlers.php(187): urlHandler->callHandler('post', '2013/01/20/C-St...') #8 /var/www/blog/inc/public/prepend.php(156): dcUrlHandlers->getDocument() #9 /var/www/blog/ind in /var/www/blog/inc/core/class.dc.postmedia.php on line 61