Andre Poenitz wrote:
> Well... this exposes an implementation detail (type of container) to
> the outer world. Moreover, people are tempted to use ++ on
> iterators, whereas not too many poeple would use (&element(3) + 1)
> 
> So _I_'d prefer the accessor functions.

Hmpfff. I did as you suggested and all is working beautifully. However, I had to 
jump through some big hoops on the way. Ahh well...

void read_scalar_field(std::istream & is,
                       char const * identifier,
                       support::size_type nnodes,
                       boost::function2<void, support::size_type, double> set_value);

template <typename Element>
void read_conc(std::istream & is, ElementList<Element> & elist)
{
        using support::size_type;

        // set_value(i, val) is equivalent to elist.node(i).set_conc(val);
        boost::function2<void, size_type, double> set_value =
                boost::bind(&Node::set_conc,
                            boost::bind(&ElementList<Element>::node, 
boost::ref(elist), _1),
                            _2);

        read_scalar_field(is, "CONCENTRATION", elist.nnodes(), set_value);
}

-- 
Angus

Reply via email to