Boost logo

Boost :

Subject: Re: [boost] [encrypted strings]
From: Eric Niebler (eric_at_[hidden])
Date: 2009-04-27 13:45:06

David Abrahams wrote:
> on Mon Apr 27 2009, Sohail Somani <> wrote:
>> There is an implementation of a mpl::string by Eric Neibler somewhere.
> well, that's an interesting point. The string itself wouldn't even
> appear in the data segment. Cool.

Below is the definition of a std_str() function that takes an
mpl::string and turns it into a std::string. (boost/mpl/string.hpp is
available on trunk, but hasn't been released yet.) It's not *very*
obfuscated, but should be enough to fool a naive string-dump.

#include <string>
#include <iostream>
#include <boost/mpl/string.hpp>
#include <boost/mpl/for_each.hpp>
using namespace boost;

struct push_back_str
     push_back_str(std::string & s)
       : str(s)

     void operator()(char c) const
     std::string & str;

template<typename String>
std::string std_str()
     std::string result;
     return result;

int main()
     std::cout << std_str< mpl::string<'hell','o wo','rld!'> >() <<
     return 0;


Eric Niebler
BoostPro Computing

Boost list run by bdawes at, gregod at, cpdaniel at, john at