On Wednesday 21 September 2011 10:46:08 Arvin Schnell wrote:
On Wed, Sep 21, 2011 at 10:19:55AM +0200, Stephan Kulow wrote:
Am Mittwoch, 21. September 2011 schrieb Michael Andres:
Just kidding, but ....
http://gitorious.org/riss
C++ can be so sexy:
vector< vector<int> >formula;
vector<int> clause;
clause.push_back(1);
clause.push_back(-2);
formula. push_back(clause);
clause.clear();
clause.push_back(-1);
clause.push_back(2);
formula. push_back(clause);
And C++11 can even be short:
vector formula = { { 1, -2 }, { -1, 2 } };
Or you can offer a little loader framework:
namespace _detail
{
template<class _C> class _Loader;
}
template<class _C>
_detail::_Loader<_C> load( _C & f )
{ return _detail::_Loader<_C>( f ); }
Provide a specialized formula loader:
namespace _detail
{
template<> class _Loader >
{
public:
_Loader( vector< vector<int> > & f ) : _f( &f ) {}
_Loader & operator()( int l, int r )
{
vector<int> clause;
clause.push_back(l);
clause.push_back(r);
_f->push_back(clause);
return *this;
}
private:
vector< vector<int> > * _f;
};
}
So you can simply write:
vector< vector<int> > formula;
load(formula)(1,2)(-1,2);
Beauty is in the eye of the beholder.
--
cu,
Michael Andres
+------------------------------------------------------------------+
Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4
+------------------------------------------------------------------+
Michael Andres SUSE LINUX Products GmbH, Development, ma@suse.de
GF:Jeff Hawn,Jennifer Guild,Felix Imendörffer, HRB16746(AG Nürnberg)
Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0
+------------------------------------------------------------------+
--
To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-devel+help@opensuse.org