C++ template meta sql
You my also want to have a look at how the Poco library achieves a similar thing using a Tuple class. From the docs:

typedef Poco::Tuple&lt;std::string, std::string, int&gt; Person;
typedef std::vector&lt;Person&gt; People;

People people;
people.push_back(Person("Bart Simpson", "Springfield", 12));
people.push_back(Person("Lisa Simpson", "Springfield", 10));

Statement insert(session);
insert &lt;&lt; "INSERT INTO Person VALUES(:name, :address, :age)",
    use(people), now;

Statement select(session);
select &lt;&lt; "SELECT Name, Address, Age FROM Person",
    into(people), now;

for (People::const_iterator it = people.begin(); it != people.end(); ++it)
{
    std::cout &lt;&lt; "Name: " &lt;&lt; it-&gt;get&lt;0&gt;() &lt;&lt; 
        ", Address: " &lt;&lt; it-&gt;get&lt;1&gt;() &lt;&lt; 
        ", Age: " &lt;&lt; it-&gt;get&lt;2&gt;() &lt;&lt;std::endl;
}