Boost logo

Boost :

Subject: [boost] [assign] How to create a container wrapper for tuple_list_of
From: Robert Dailey (rcdailey.lists_at_[hidden])
Date: 2012-04-26 16:53:50

I have a vector of boost::tuple objects that is a member variable in a
class of mine. I want to be able to create an instance of my wrapper class
and construct it off of a tuple_list_of(), and essentially forward those
values to the container itself. I haven't seen a way to do this yet. An
example is below. Note that my constructor in the class was my attempt to
get this working, but instead it will not compile. For some reason
boost.assign thinks that the EnumErrorInfo class is the container.

template<class T>
class EnumErrorInfo
typedef boost::tuple<T, char const*, char const*> Tuple;
typedef std::vector<Tuple> TupleVector;

EnumErrorInfo( TupleVector const& assignment )
: m_errorInfo( assignment )

Tuple const& getErrorInfo( T error_code )
TupleVector::const_iterator it =
std::find_if( m_errorInfo.begin(), m_errorInfo.end(), MatchErrorCodePred(
error_code ) );

if( it != m_errorInfo.end() ) {
return *it;

static Tuple const unknown_info( error_code, "????", "No error info
available for this code" );
return unknown_info;

class MatchErrorCodePred
MatchErrorCodePred( T error_code )
: m_errorCode( error_code )

bool operator() ( Tuple const& t )
return t.get<0>() == m_errorCode;

DomInterfaceErrors m_errorCode;

TupleVector m_errorInfo;

And here is how I'd like to initialize the class:

EnumErrorInfo<DomInterfaceErrors> g_errorInfo = tuple_list_of
    ( GDE_OK, "GDE_OK", "DBL: Opeartion successfully completed" )
    ( GDE_GDD_DIRUSERS, "GDE_GDD_DIRUSERS", "AQX: Unable to get directory
users." )

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