|
Boost : |
Subject: [boost] [fusion] Quick start in doc - Something to modify ?
From: Alp Mestan (alp.boost-dev_at_[hidden])
Date: 2008-10-15 04:40:26
Hi Boosters,
I've been reading the Boost.Fusion documentation and I saw an "error" on the
Quick Start page :
http://spirit.sourceforge.net/dl_more/fusion_v2/libs/fusion/doc/html/fusion/quick_start.html
The given code is :
#include <boost/fusion/sequence.hpp>
#include <boost/fusion/include/sequence.hpp>
// ...
vector <http://spirit.sourceforge.net/dl_more/fusion_v2/libs/fusion/doc/html/fusion/container/vector.html><int,
char, std::string> stuff(1, 'x', "howdy");
int i = at_c <http://spirit.sourceforge.net/dl_more/fusion_v2/libs/fusion/doc/html/fusion/sequence/intrinsic/functions/at_c.html><0>(stuff);
char ch = at_c <http://spirit.sourceforge.net/dl_more/fusion_v2/libs/fusion/doc/html/fusion/sequence/intrinsic/functions/at_c.html><1>(stuff);
std::string s = at_c
<http://spirit.sourceforge.net/dl_more/fusion_v2/libs/fusion/doc/html/fusion/sequence/intrinsic/functions/at_c.html><2>(stuff);
But this way we never get any vector.hpp included. (however I'm on the
svn version... maybe on 1.36 one of the sequence.hpp includes
vector... but I think it is rather the one in the container dir)
And I think such an error makes people let Fusion down, so here is a
"minimal" code that would have a much better effect, IMO, on fusion's
doc readers.
#include <boost/fusion/sequence.hpp> // for boost::fusion::at_c
#include <boost/fusion/include/vector.hpp> // for boost::fusion::vector
#include <iostream>
#include <string>
using namespace boost::fusion;
int main()
{
vector<int, char, std::string> stuff(1, 'x', "howdy");
int i = at_c<0>(stuff);
char ch = at_c<1>(stuff);
std::string s = at_c<2>(stuff);
std::cout << "(" << i << "," << ch << "," << s << ")" << std::endl;
return 0;
}
This way, they'd just have to copy, paste, compile & launch to see Fusion in
action, which would make them read the rest of the doc more happily.
Hope it helps.
-- Alp Mestan --- http://blog.mestan.fr/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk