Index: .hgignore
===================================================================
--- .hgignore	(revision 9)
+++ .hgignore	(revision 85)
@@ -33,2 +33,3 @@
 ^objs.*/.*
 ^test/[a-z_]*$
+^demo/.*_demo$
Index: configure.ac
===================================================================
--- configure.ac	(revision 64)
+++ configure.ac	(revision 91)
@@ -11,5 +11,5 @@
 
 AC_PREREQ([2.59])
-AC_INIT([LEMON], [lemon_version()], [etik-ol@cs.elte.hu], [lemon])
+AC_INIT([LEMON], [lemon_version()], [lemon-devel@lemon.cs.elte.hu], [lemon])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_MACRO_DIR([m4])
Index: demo/Makefile.am
===================================================================
--- demo/Makefile.am	(revision 1)
+++ demo/Makefile.am	(revision 85)
@@ -4,5 +4,9 @@
 if WANT_DEMO
 
-noinst_PROGRAMS +=
+noinst_PROGRAMS += \
+        demo/arg_parser_demo
 
 endif WANT_DEMO
+
+demo_arg_parser_demo_SOURCES = demo/arg_parser_demo.cc
+
Index: demo/arg_parser_demo.cc
===================================================================
--- demo/arg_parser_demo.cc	(revision 88)
+++ demo/arg_parser_demo.cc	(revision 88)
@@ -0,0 +1,82 @@
+/* -*- C++ -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2003-2008
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+///\ingroup demos
+///\file
+///\brief Argument parser demo
+///
+/// This example shows how the argument parser can be used.
+///
+/// \include arg_parser_demo.cc
+
+#include <lemon/arg_parser.h>
+
+using namespace lemon;
+int main(int argc, const char **argv)
+{
+  ArgParser ap(argc,argv);
+  int i;
+  std::string s;
+  double d;
+  bool b,sil;
+  bool g1,g2,g3;
+  ap.refOption("n", "An integer input.", i, true)
+    .refOption("val", "A double input.", d)
+    .synonym("vals","val")
+    .refOption("name", "A string input.", s)
+    .refOption("f", "A switch.", b)
+    .refOption("nohelp", "", sil)
+    .refOption("gra","Choice A",g1)
+    .refOption("grb","Choice B",g2)
+    .refOption("grc","Choice C",g3)
+    .optionGroup("gr","gra")
+    .optionGroup("gr","grb")
+    .optionGroup("gr","grc")
+    .mandatoryGroup("gr")
+    .onlyOneGroup("gr")
+    .other("infile","The input file.")
+    .other("...");
+  
+  ap.parse();
+
+  std::cout << "Parameters of '" << ap.commandName() << "':\n";
+
+  if(ap.given("n")) std::cout << "  Value of -n: " << i << std::endl;
+  if(ap.given("val")) std::cout << "  Value of -val: " << d << std::endl;
+  if(ap.given("name")) std::cout << "  Value of -name: " << s << std::endl;
+  if(ap.given("f")) std::cout << "  -f is given\n";
+  if(ap.given("nohelp")) std::cout << "  Value of -nohelp: " << sil << std::endl;
+  if(ap.given("gra")) std::cout << "  -gra is given\n";
+  if(ap.given("grb")) std::cout << "  -grb is given\n";
+  if(ap.given("grc")) std::cout << "  -grc is given\n";
+                                     
+  switch(ap.files().size()) {
+  case 0:
+    std::cout << "  No file argument was given.\n";
+    break;
+  case 1:
+    std::cout << "  1 file argument was given. It is:\n";
+    break;
+  default:
+    std::cout << "  "
+	      << ap.files().size() << " file arguments were given. They are:\n";
+  }
+  for(unsigned int i=0;i<ap.files().size();++i)
+    std::cout << "    '" << ap.files()[i] << "'\n";
+  
+}
Index: doc/groups.dox
===================================================================
--- doc/groups.dox	(revision 71)
+++ doc/groups.dox	(revision 83)
@@ -39,5 +39,5 @@
 the diverging requirements of the possible users.  In order to save on
 running time or on memory usage, some structures may fail to provide
-some graph features like edge or node deletion.
+some graph features like arc/edge or node deletion.
 
 Alteration of standard containers need a very limited number of 
@@ -45,5 +45,5 @@
 In the case of graph structures, different operations are needed which do 
 not alter the physical graph, but gives another view. If some nodes or 
-edges have to be hidden or the reverse oriented graph have to be used, then 
+arcs have to be hidden or the reverse oriented graph have to be used, then
 this is the case. It also may happen that in a flow implementation 
 the residual graph can be accessed by another algorithm, or a node-set 
@@ -82,8 +82,8 @@
 @defgroup graph_maps Graph Maps 
 @ingroup maps
-\brief Special Graph-Related Maps.
+\brief Special graph-related maps.
 
 This group describes maps that are specifically designed to assign
-values to the nodes and edges of graphs.
+values to the nodes and arcs of graphs.
 */
 
@@ -97,13 +97,13 @@
 maps from other maps.
 
-Most of them are \ref lemon::concepts::ReadMap "ReadMap"s. They can
-make arithmetic operations between one or two maps (negation, scaling,
-addition, multiplication etc.) or e.g. convert a map to another one
-of different Value type.
+Most of them are \ref lemon::concepts::ReadMap "read-only maps".
+They can make arithmetic and logical operations between one or two maps
+(negation, shifting, addition, multiplication, logical 'and', 'or',
+'not' etc.) or e.g. convert a map to another one of different Value type.
 
 The typical usage of this classes is passing implicit maps to
 algorithms.  If a function type algorithm is called then the function
 type map adaptors can be used comfortable. For example let's see the
-usage of map adaptors with the \c graphToEps() function:
+usage of map adaptors with the \c digraphToEps() function.
 \code
   Color nodeColor(int deg) {
@@ -117,15 +117,15 @@
   }
   
-  Graph::NodeMap<int> degree_map(graph);
+  Digraph::NodeMap<int> degree_map(graph);
   
-  graphToEps(graph, "graph.eps")
+  digraphToEps(graph, "graph.eps")
     .coords(coords).scaleToA4().undirected()
-    .nodeColors(composeMap(functorMap(nodeColor), degree_map)) 
+    .nodeColors(composeMap(functorToMap(nodeColor), degree_map))
     .run();
 \endcode 
-The \c functorMap() function makes an \c int to \c Color map from the
+The \c functorToMap() function makes an \c int to \c Color map from the
 \e nodeColor() function. The \c composeMap() compose the \e degree_map
-and the previous created map. The composed map is proper function to
-get color of each node.
+and the previously created map. The composed map is a proper function to
+get the color of each node.
 
 The usage with class type algorithms is little bit harder. In this
@@ -133,21 +133,19 @@
 function map adaptors give back temporary objects.
 \code
-  Graph graph;
-  
-  typedef Graph::EdgeMap<double> DoubleEdgeMap;
-  DoubleEdgeMap length(graph);
-  DoubleEdgeMap speed(graph);
-  
-  typedef DivMap<DoubleEdgeMap, DoubleEdgeMap> TimeMap;
-  
+  Digraph graph;
+
+  typedef Digraph::ArcMap<double> DoubleArcMap;
+  DoubleArcMap length(graph);
+  DoubleArcMap speed(graph);
+
+  typedef DivMap<DoubleArcMap, DoubleArcMap> TimeMap;
   TimeMap time(length, speed);
   
-  Dijkstra<Graph, TimeMap> dijkstra(graph, time);
+  Dijkstra<Digraph, TimeMap> dijkstra(graph, time);
   dijkstra.run(source, target);
 \endcode
-
-We have a length map and a maximum speed map on a graph. The minimum
-time to pass the edge can be calculated as the division of the two
-maps which can be done implicitly with the \c DivMap template
+We have a length map and a maximum speed map on the arcs of a digraph.
+The minimum time to pass the arc can be calculated as the division of
+the two maps which can be done implicitly with the \c DivMap template
 class. We use the implicit minimum time map as the length map of the
 \c Dijkstra algorithm.
@@ -316,5 +314,5 @@
 This group contains algorithm objects and functions to calculate
 matchings in graphs and bipartite graphs. The general matching problem is
-finding a subset of the edges which does not shares common endpoints.
+finding a subset of the arcs which does not shares common endpoints.
  
 There are several different algorithms for calculate matchings in
Index: lemon/Makefile.am
===================================================================
--- lemon/Makefile.am	(revision 69)
+++ lemon/Makefile.am	(revision 89)
@@ -8,4 +8,5 @@
 
 lemon_libemon_la_SOURCES = \
+        lemon/arg_parser.cc \
         lemon/base.cc \
         lemon/random.cc
@@ -16,4 +17,5 @@
 
 lemon_HEADERS += \
+        lemon/arg_parser.h \
         lemon/concept_check.h \
         lemon/dim2.h \
Index: lemon/arg_parser.cc
===================================================================
--- lemon/arg_parser.cc	(revision 88)
+++ lemon/arg_parser.cc	(revision 88)
@@ -0,0 +1,465 @@
+/* -*- C++ -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2003-2008
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+#include <lemon/arg_parser.h>
+
+namespace lemon {
+
+  void ArgParser::_showHelp(void *p)
+  {
+    (static_cast<ArgParser*>(p))->showHelp();
+    exit(1);
+  }
+
+  ArgParser::ArgParser(int argc, const char **argv) :_argc(argc), _argv(argv),
+                                                     _command_name(argv[0]) {
+    funcOption("-help","Print a short help message",_showHelp,this);
+    synonym("help","-help");
+    synonym("h","-help");
+
+  }
+
+  ArgParser::~ArgParser()
+  {
+    for(Opts::iterator i=_opts.begin();i!=_opts.end();++i)
+      if(i->second.self_delete)
+	switch(i->second.type) {
+	case BOOL:
+	  delete i->second.bool_p;
+	  break;
+	case STRING:
+	  delete i->second.string_p;
+	  break;
+	case DOUBLE:
+	  delete i->second.double_p;
+	  break;
+	case INTEGER:
+	  delete i->second.int_p;
+	  break;
+	case UNKNOWN:
+	  break;
+	case FUNC:
+	  break;
+	}
+  }
+  
+
+  ArgParser &ArgParser::intOption(const std::string &name,
+			       const std::string &help,
+			       int value, bool obl)
+  {
+    ParData p;
+    p.int_p=new int(value);
+    p.self_delete=true;
+    p.help=help;
+    p.type=INTEGER;
+    p.mandatory=obl;
+    _opts[name]=p;
+    return *this;
+  }
+
+  ArgParser &ArgParser::doubleOption(const std::string &name,
+			       const std::string &help,
+			       double value, bool obl)
+  {
+    ParData p;
+    p.double_p=new double(value);
+    p.self_delete=true;
+    p.help=help;
+    p.type=DOUBLE;
+    p.mandatory=obl;
+    _opts[name]=p;
+    return *this;
+  }
+
+  ArgParser &ArgParser::boolOption(const std::string &name,
+			       const std::string &help,
+			       bool value, bool obl)
+  {
+    ParData p;
+    p.bool_p=new bool(value);
+    p.self_delete=true;
+    p.help=help;
+    p.type=BOOL;
+    p.mandatory=obl;
+    _opts[name]=p;
+    return *this;
+  }
+
+  ArgParser &ArgParser::stringOption(const std::string &name,
+			       const std::string &help,
+			       std::string value, bool obl)
+  {
+    ParData p;
+    p.string_p=new std::string(value);
+    p.self_delete=true;
+    p.help=help;
+    p.type=STRING;
+    p.mandatory=obl;
+    _opts[name]=p;
+    return *this;
+  }
+
+  ArgParser &ArgParser::refOption(const std::string &name,
+			       const std::string &help,
+			       int &ref, bool obl)
+  {
+    ParData p;
+    p.int_p=&ref;
+    p.self_delete=false;
+    p.help=help;
+    p.type=INTEGER;
+    p.mandatory=obl;
+    _opts[name]=p;
+    return *this;
+  }
+
+  ArgParser &ArgParser::refOption(const std::string &name,
+                                  const std::string &help,
+                                  double &ref, bool obl)
+  {
+    ParData p;
+    p.double_p=&ref;
+    p.self_delete=false;
+    p.help=help;
+    p.type=DOUBLE;
+    p.mandatory=obl;
+    _opts[name]=p;
+    return *this;
+  }
+
+  ArgParser &ArgParser::refOption(const std::string &name,
+                                  const std::string &help,
+                                  bool &ref, bool obl)
+  {
+    ParData p;
+    p.bool_p=&ref;
+    p.self_delete=false;
+    p.help=help;
+    p.type=BOOL;
+    p.mandatory=obl;
+    _opts[name]=p;
+
+    ref = false;
+
+    return *this;
+  }
+
+  ArgParser &ArgParser::refOption(const std::string &name,
+			       const std::string &help,
+			       std::string &ref, bool obl)
+  {
+    ParData p;
+    p.string_p=&ref;
+    p.self_delete=false;
+    p.help=help;
+    p.type=STRING;
+    p.mandatory=obl;
+    _opts[name]=p;
+    return *this;
+  }
+
+  ArgParser &ArgParser::funcOption(const std::string &name,
+			       const std::string &help,
+			       void (*func)(void *),void *data)
+  {
+    ParData p;
+    p.func_p.p=func;
+    p.func_p.data=data;
+    p.self_delete=false;
+    p.help=help;
+    p.type=FUNC;
+    p.mandatory=false;
+    _opts[name]=p;
+    return *this;
+  }
+
+  ArgParser &ArgParser::optionGroup(const std::string &group,
+				    const std::string &opt)
+  {
+    Opts::iterator i = _opts.find(opt);
+    LEMON_ASSERT(i!=_opts.end(), "Unknown option: '"+opt+"'");
+    LEMON_ASSERT(!(i->second.ingroup), 
+                 "Option already in option group: '"+opt+"'");
+    GroupData &g=_groups[group];
+    g.opts.push_back(opt);
+    i->second.ingroup=true;
+    return *this;
+  }
+
+  ArgParser &ArgParser::onlyOneGroup(const std::string &group)
+  {
+    GroupData &g=_groups[group];
+    g.only_one=true;
+    return *this;
+  }
+
+  ArgParser &ArgParser::synonym(const std::string &syn,
+				const std::string &opt)
+  {
+    Opts::iterator o = _opts.find(opt);
+    Opts::iterator s = _opts.find(syn);
+    LEMON_ASSERT(o!=_opts.end(), "Unknown option: '"+opt+"'");
+    LEMON_ASSERT(s==_opts.end(), "Option already used: '"+syn+"'");
+    ParData p;
+    p.help=opt;
+    p.mandatory=false;
+    p.syn=true;
+    _opts[syn]=p;
+    o->second.has_syn=true;
+    return *this;
+  }
+
+  ArgParser &ArgParser::mandatoryGroup(const std::string &group)
+  {
+    GroupData &g=_groups[group];
+    g.mandatory=true;
+    return *this;
+  }
+
+  ArgParser &ArgParser::other(const std::string &name,
+			      const std::string &help)
+  {
+    _others_help.push_back(OtherArg(name,help));
+    return *this;
+  }
+
+  void ArgParser::show(std::ostream &os,Opts::iterator i)
+  {
+    os << "-" << i->first;
+    if(i->second.has_syn)
+      for(Opts::iterator j=_opts.begin();j!=_opts.end();++j)
+	if(j->second.syn&&j->second.help==i->first)
+	  os << "|-" << j->first;
+    switch(i->second.type) {
+    case STRING:
+      os << " str";
+      break;
+    case INTEGER:
+      os << " int";
+      break;
+    case DOUBLE:
+      os << " num";
+      break;
+    default:
+      break;
+    }
+  }
+
+  void ArgParser::show(std::ostream &os,Groups::iterator i)
+  {
+    GroupData::Opts::iterator o=i->second.opts.begin();
+    while(o!=i->second.opts.end()) {
+      show(os,_opts.find(*o));
+      ++o;
+      if(o!=i->second.opts.end()) os<<'|';
+    }
+  }
+    
+  void ArgParser::showHelp(Opts::iterator i)
+  {
+    if(i->second.help.size()==0||i->second.syn) return;
+    std::cerr << "  ";
+    show(std::cerr,i);
+    std::cerr << std::endl;
+    std::cerr << "     " << i->second.help << std::endl;
+  }
+  void ArgParser::showHelp(std::vector<ArgParser::OtherArg>::iterator i)
+  {
+    if(i->help.size()==0) return;
+    std::cerr << "  " << i->name << std::endl
+	      << "     " << i->help << std::endl;
+  }
+    
+  void ArgParser::shortHelp()
+  {
+    const unsigned int LINE_LEN=77;
+    const std::string indent("    ");
+    std::cerr << "Usage:\n  " << _command_name;
+    int pos=_command_name.size()+2;
+    for(Groups::iterator g=_groups.begin();g!=_groups.end();++g) {
+      std::ostringstream cstr;
+      cstr << ' ';
+      if(!g->second.mandatory) cstr << '[';
+      show(cstr,g);
+      if(!g->second.mandatory) cstr << ']';
+      if(pos+cstr.str().size()>LINE_LEN) {
+	std::cerr << std::endl << indent;
+	pos=indent.size();
+      }
+      std::cerr << cstr.str();
+      pos+=cstr.str().size();
+    }
+    for(Opts::iterator i=_opts.begin();i!=_opts.end();++i)
+      if(!i->second.ingroup&&!i->second.syn) {
+	std::ostringstream cstr;
+	cstr << ' ';
+	if(!i->second.mandatory) cstr << '[';
+	show(cstr,i);
+	if(!i->second.mandatory) cstr << ']';
+	if(pos+cstr.str().size()>LINE_LEN) {
+	  std::cerr << std::endl << indent;
+	  pos=indent.size();
+	}
+	std::cerr << cstr.str();
+	pos+=cstr.str().size();
+      }
+    for(std::vector<OtherArg>::iterator i=_others_help.begin();
+	i!=_others_help.end();++i)
+      {
+	std::ostringstream cstr;
+	cstr << ' ' << i->name;
+      
+	if(pos+cstr.str().size()>LINE_LEN) {
+	  std::cerr << std::endl << indent;
+	  pos=indent.size();
+	}
+	std::cerr << cstr.str();
+	pos+=cstr.str().size();
+      }
+    std::cerr << std::endl;
+  }
+    
+  void ArgParser::showHelp()
+  {
+    shortHelp();
+    std::cerr << "Where:\n";
+    for(std::vector<OtherArg>::iterator i=_others_help.begin();
+	i!=_others_help.end();++i) showHelp(i);
+    for(Opts::iterator i=_opts.begin();i!=_opts.end();++i) showHelp(i);
+    exit(1);
+  }
+    
+      
+  void ArgParser::unknownOpt(std::string arg) 
+  {
+    std::cerr << "\nUnknown option: " << arg << "\n";
+    std::cerr << "\nType '" << _command_name <<
+      " --help' to obtain a short summary on the usage.\n\n";
+    exit(1);
+  }
+    
+  void ArgParser::requiresValue(std::string arg, OptType t) 
+  {
+    std::cerr << "Argument '" << arg << "' requires a";
+    switch(t) {
+    case STRING:
+      std::cerr << " string";
+      break;
+    case INTEGER:
+      std::cerr << "n integer";
+      break;
+    case DOUBLE:
+      std::cerr << " floating point";
+      break;
+    default:
+      break;
+    }
+    std::cerr << " value\n\n";
+    showHelp();
+  }
+    
+
+  void ArgParser::checkMandatories()
+  {
+    bool ok=true;
+    for(Opts::iterator i=_opts.begin();i!=_opts.end();++i)
+      if(i->second.mandatory&&!i->second.set) 
+	{
+	  if(ok)
+	    std::cerr << _command_name 
+		      << ": The following mandatory arguments are missing.\n";
+	  ok=false;
+	  showHelp(i);
+	}
+    for(Groups::iterator i=_groups.begin();i!=_groups.end();++i)
+      if(i->second.mandatory||i->second.only_one)
+	{
+	  int set=0;
+	  for(GroupData::Opts::iterator o=i->second.opts.begin();
+	      o!=i->second.opts.end();++o)
+	    if(_opts.find(*o)->second.set) ++set;
+	  if(i->second.mandatory&&!set) {
+	    std::cerr << _command_name 
+		      << ": At least one of the following arguments is mandatory.\n";
+	    ok=false;
+	    for(GroupData::Opts::iterator o=i->second.opts.begin();
+		o!=i->second.opts.end();++o)
+	      showHelp(_opts.find(*o));
+	  }
+	  if(i->second.only_one&&set>1) {
+	    std::cerr << _command_name 
+		      << ": At most one of the following arguments can be given.\n";
+	    ok=false;
+	    for(GroupData::Opts::iterator o=i->second.opts.begin();
+		o!=i->second.opts.end();++o)
+	      showHelp(_opts.find(*o));
+	  }
+	}
+    if(!ok) {
+      std::cerr << "\nType '" << _command_name <<
+	" --help' to obtain a short summary on the usage.\n\n";
+      exit(1);
+    }
+  }
+
+  ArgParser &ArgParser::parse()
+  {
+    for(int ar=1; ar<_argc; ++ar) {
+      std::string arg(_argv[ar]);
+      if (arg[0] != '-' || arg.size() == 1) {
+	_file_args.push_back(arg);
+      }
+      else {
+	Opts::iterator i = _opts.find(arg.substr(1));
+	if(i==_opts.end()) unknownOpt(arg);
+	else {
+	  if(i->second.syn) i=_opts.find(i->second.help);
+	  ParData &p(i->second);
+	  if (p.type==BOOL) *p.bool_p=true;
+	  else if (p.type==FUNC) p.func_p.p(p.func_p.data);
+	  else if(++ar==_argc) requiresValue(arg, p.type);
+	  else {
+	    std::string val(_argv[ar]);
+	    std::istringstream vals(val);
+	    switch(p.type) {
+	    case STRING:
+	      *p.string_p=val;
+	      break;
+	    case INTEGER:
+	      vals >> *p.int_p;
+	      break;
+	    case DOUBLE:
+	      vals >> *p.double_p;
+	      break;
+	    default:
+	      break;
+	    }
+	    if(p.type!=STRING&&(!vals||!vals.eof()))
+	      requiresValue(arg, p.type);
+	  }
+	  p.set = true;
+	}
+      }
+    }
+    checkMandatories();
+
+    return *this;
+  }  
+
+}
Index: lemon/arg_parser.h
===================================================================
--- lemon/arg_parser.h	(revision 90)
+++ lemon/arg_parser.h	(revision 90)
@@ -0,0 +1,369 @@
+/* -*- C++ -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2003-2008
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+#ifndef LEMON_ARG_PARSER
+#define LEMON_ARG_PARSER
+
+#include <vector>
+#include <map>
+#include <list>
+#include <string>
+#include <iostream>
+#include <sstream>
+#include <algorithm>
+#include <lemon/error.h>
+
+///\ingroup misc
+///\file
+///\brief A tool to parse command line arguments.
+
+namespace lemon {
+
+  ///Command line arguments parser
+
+  ///\ingroup misc
+  ///Command line arguments parser.
+  ///
+  ///For a complete example see the \ref arg_parser_demo.cc demo file.
+  class ArgParser {
+    
+    static void _showHelp(void *p);
+  protected:
+    
+    int _argc;
+    const char **_argv;
+    
+    enum OptType { UNKNOWN=0, BOOL=1, STRING=2, DOUBLE=3, INTEGER=4, FUNC=5 };
+    
+    class ParData {
+    public:
+      union {
+	bool *bool_p;
+	int *int_p;
+	double *double_p;
+	std::string *string_p;
+	struct {
+	  void (*p)(void *);
+	  void *data;
+	} func_p;
+	  
+      };
+      std::string help;
+      bool mandatory;
+      OptType type;
+      bool set;
+      bool ingroup;
+      bool has_syn;
+      bool syn;
+      bool self_delete;
+      ParData() : mandatory(false), type(UNKNOWN), set(false), ingroup(false),
+		  has_syn(false), syn(false), self_delete(false) {}
+    };
+
+    typedef std::map<std::string,ParData> Opts;
+    Opts _opts;
+
+    class GroupData 
+    {
+    public:
+      typedef std::list<std::string> Opts;
+      Opts opts;
+      bool only_one;
+      bool mandatory;
+      GroupData() :only_one(false), mandatory(false) {}
+    };
+      
+    typedef std::map<std::string,GroupData> Groups;
+    Groups _groups;
+
+    struct OtherArg
+    {
+      std::string name;
+      std::string help;
+      OtherArg(std::string n, std::string h) :name(n), help(h) {}
+
+    };
+      
+    std::vector<OtherArg> _others_help;
+    std::vector<std::string> _file_args;
+    std::string _command_name;
+
+    
+  private:
+    //Bind a function to an option.
+
+    //\param name The name of the option. The leading '-' must be omitted.
+    //\param help A help string.
+    //\retval func The function to be called when the option is given. It
+    //  must be of type "void f(void *)"
+    //\param data Data to be passed to \c func
+    ArgParser &funcOption(const std::string &name,
+		    const std::string &help,
+		    void (*func)(void *),void *data);
+    
+  public:
+
+    ///\e
+    ArgParser(int argc, const char **argv);
+
+    ~ArgParser();
+
+    ///Add a new integer type option
+
+    ///\param name The name of the option. The leading '-' must be omitted.
+    ///\param help A help string.
+    ///\param value A default value for the option
+    ///\param obl Indicate if the option is mandatory.
+    ArgParser &intOption(const std::string &name,
+		    const std::string &help,
+		    int value=0, bool obl=false);
+
+    ///Add a new floating point type option
+
+    ///\param name The name of the option. The leading '-' must be omitted.
+    ///\param help A help string.
+    ///\param value A default value for the option
+    ///\param obl Indicate if the option is mandatory.
+    ArgParser &doubleOption(const std::string &name,
+		      const std::string &help,
+		      double value=0, bool obl=false);
+
+    ///Add a new bool type option
+
+    ///\param name The name of the option. The leading '-' must be omitted.
+    ///\param help A help string.
+    ///\param value A default value for the option
+    ///\param obl Indicate if the option is mandatory.
+    ////\note A mandatory bool obtion is of very little use.)
+    ArgParser &boolOption(const std::string &name,
+		      const std::string &help,
+		      bool value=false, bool obl=false);
+
+    ///Add a new string type option
+
+    ///\param name The name of the option. The leading '-' must be omitted.
+    ///\param help A help string.
+    ///\param value A default value for the option
+    ///\param obl Indicate if the option is mandatory.
+    ArgParser &stringOption(const std::string &name,
+		      const std::string &help,
+		      std::string value="", bool obl=false);
+
+    ///\name Options with external storage
+    ///Using this functions, the value of the option will be directly written
+    ///into a variable once the option appears in the command line.
+
+    ///@{
+
+    ///Add a new integer type option with a storage reference
+
+    ///\param name The name of the option. The leading '-' must be omitted.
+    ///\param help A help string.
+    ///\param obl Indicate if the option is mandatory.
+    ///\retval ref The value of the argument will be written to this variable.
+    ArgParser &refOption(const std::string &name,
+		    const std::string &help,
+		    int &ref, bool obl=false);
+
+    ///Add a new floating type option with a storage reference
+
+    ///\param name The name of the option. The leading '-' must be omitted.
+    ///\param help A help string.
+    ///\param obl Indicate if the option is mandatory.
+    ///\retval ref The value of the argument will be written to this variable.
+    ArgParser &refOption(const std::string &name,
+		      const std::string &help,
+		      double &ref, bool obl=false);
+
+    ///Add a new bool type option with a storage reference
+
+    ///\param name The name of the option. The leading '-' must be omitted.
+    ///\param help A help string.
+    ///\param obl Indicate if the option is mandatory.
+    ///\retval ref The value of the argument will be written to this variable.
+    ////\note A mandatory bool obtion is of very little use.)
+    ArgParser &refOption(const std::string &name,
+		      const std::string &help,
+		      bool &ref, bool obl=false);
+
+    ///Add a new string type option with a storage reference
+
+    ///\param name The name of the option. The leading '-' must be omitted.
+    ///\param help A help string.
+    ///\retval ref The value of the argument will be written to this variable.
+    ///\param obl Indicate if the option is mandatory.
+    ArgParser &refOption(const std::string &name,
+		      const std::string &help,
+		      std::string &ref, bool obl=false);
+    
+    ///@}
+
+    ///\name Option Groups and Synonyms
+    ///
+    
+    ///@{
+
+    ///Boundle some options into a group
+
+    /// You can group some option by calling this function repeatedly for each
+    /// option to be grouped with the same groupname.
+    ///\param group The group name.
+    ///\param opt The option name.
+    ArgParser &optionGroup(const std::string &group,
+			   const std::string &opt);
+
+    ///Make the members of a group exclusive
+
+    ///If you call this function for a group, than at most one of them can be
+    ///given at the same time
+    ArgParser &onlyOneGroup(const std::string &group);
+  
+    ///Make a group mandatory
+
+    ///Using this function, at least one of the members of \c group
+    ///must be given.
+    ArgParser &mandatoryGroup(const std::string &group);
+    
+    ///Create synonym to an option
+
+    ///With this function you can create a synonym \c syn of the
+    ///option \c opt.
+    ArgParser &synonym(const std::string &syn,
+			   const std::string &opt);
+    
+    ///@}
+
+    ///Give help string for non-parsed arguments.
+
+    ///With this function you can give help string for non-parsed arguments.
+    ///The parameter \c name will be printed in the short usage line, while
+    ///\c help gives a more detailed description.
+    ArgParser &other(const std::string &name,
+		     const std::string &help="");
+    
+    ///Give back the non-option type arguments.
+
+    ///Give back a reference to a vector consisting of the program arguments
+    ///not starting with a '-' character.
+    std::vector<std::string> &files() { return _file_args; }
+
+    ///Give back the command name (the 0th argument)
+    const std::string &commandName() { return _command_name; }
+
+    void show(std::ostream &os,Opts::iterator i);
+    void show(std::ostream &os,Groups::iterator i);
+    void showHelp(Opts::iterator i);
+    void showHelp(std::vector<OtherArg>::iterator i);
+    void shortHelp();
+    void showHelp();
+
+    void unknownOpt(std::string arg);
+
+    void requiresValue(std::string arg, OptType t);
+    void checkMandatories();
+    
+    ///Start the parsing process
+    ArgParser &parse();
+
+    /// Synonym for parse()
+    ArgParser &run() 
+    {
+      return parse();
+    }
+    
+    ///Check if an opion has been given to the command.
+    bool given(std::string op) 
+    {
+      Opts::iterator i = _opts.find(op);
+      return i!=_opts.end()?i->second.set:false;
+    }
+
+
+    ///Magic type for operator[]
+    
+    ///This is the type of the return value of ArgParser::operator[]().
+    ///It automatically converts to \c int, \c double, \c bool or
+    ///\c std::string if the type of the option matches, otherwise it
+    ///throws an exception (i.e. it performs runtime type checking).
+    class RefType 
+    {
+      ArgParser &_parser;
+      std::string _name;
+    public:
+      ///\e
+      RefType(ArgParser &p,const std::string &n) :_parser(p),_name(n) {}
+      ///\e
+      operator bool() 
+      {
+	Opts::iterator i = _parser._opts.find(_name);
+	LEMON_ASSERT(i==_parser._opts.end(),
+		     std::string()+"Unkown option: '"+_name+"'");
+	LEMON_ASSERT(i->second.type!=ArgParser::BOOL,
+		     std::string()+"'"+_name+"' is a bool option");
+	return *(i->second.bool_p);
+      }
+      ///\e
+      operator std::string()
+      {
+	Opts::iterator i = _parser._opts.find(_name);
+	LEMON_ASSERT(i==_parser._opts.end(),
+		     std::string()+"Unkown option: '"+_name+"'");
+	LEMON_ASSERT(i->second.type!=ArgParser::STRING,
+		     std::string()+"'"+_name+"' is a string option");
+	return *(i->second.string_p);
+      }
+      ///\e
+      operator double() 
+      {
+	Opts::iterator i = _parser._opts.find(_name);
+	LEMON_ASSERT(i==_parser._opts.end(),
+		     std::string()+"Unkown option: '"+_name+"'");
+	LEMON_ASSERT(i->second.type!=ArgParser::DOUBLE &&
+		     i->second.type!=ArgParser::INTEGER,
+		     std::string()+"'"+_name+"' is a floating point option");
+	return i->second.type==ArgParser::DOUBLE ?
+	  *(i->second.double_p) : *(i->second.int_p);
+      }
+      ///\e
+      operator int() 
+      {
+	Opts::iterator i = _parser._opts.find(_name);
+	LEMON_ASSERT(i==_parser._opts.end(),
+		     std::string()+"Unkown option: '"+_name+"'");
+	LEMON_ASSERT(i->second.type!=ArgParser::INTEGER,
+		     std::string()+"'"+_name+"' is an integer option");
+	return *(i->second.int_p);
+      }
+
+    };
+
+    ///Give back the value of an option
+    
+    ///Give back the value of an option.
+    ///\sa RefType
+    RefType operator[](const std::string &n)
+    {
+      return RefType(*this, n);
+    }    
+ 
+  };
+}
+
+    
+
+#endif // LEMON_MAIN_PARAMS
Index: lemon/concepts/maps.h
===================================================================
--- lemon/concepts/maps.h	(revision 74)
+++ lemon/concepts/maps.h	(revision 79)
@@ -30,5 +30,5 @@
 
   namespace concepts {
-  
+
     /// \addtogroup concept
     /// @{
@@ -43,14 +43,13 @@
     public:
       /// The key type of the map.
-      typedef K Key;    
-      /// The value type of the map. (The type of objects associated with the keys).
-      typedef T Value;
-
-      /// Returns the value associated with a key.
-
-      /// Returns the value associated with a key.
-      /// \bug Value shouldn't need to be default constructible.
-      ///
-      Value operator[](const Key &) const {return Value();}
+      typedef K Key;
+      /// The value type of the map. (The type of objects associated with the keys).
+      typedef T Value;
+
+      /// Returns the value associated with the given key.
+
+      /// Returns the value associated with the given key.
+      /// \bug Value shouldn't need to be default constructible. 
+      Value operator[](const Key &) const { return Value(); }
 
       template<typename _ReadMap>
@@ -59,44 +58,7 @@
 	  Value val = m[key];
 	  val = m[key];
-	  typename _ReadMap::Value own_val = m[own_key]; 
-	  own_val = m[own_key]; 
-
-	  ignore_unused_variable_warning(val);
-	  ignore_unused_variable_warning(own_val);
-	  ignore_unused_variable_warning(key);
-	}
-	Key& key;
-	typename _ReadMap::Key& own_key;
-	_ReadMap& m;
-      };
-      
-    };
-
-
-    /// Writable map concept
-    
-    /// Writable map concept.
-    ///
-    template<typename K, typename T>
-    class WriteMap
-    {
-    public:
-      /// The key type of the map.
-      typedef K Key;    
-      /// The value type of the map. (The type of objects associated with the keys).
-      typedef T Value;
-
-      /// Sets the value associated with a key.
-      void set(const Key &,const Value &) {}
-
-      ///Default constructor
-      WriteMap() {}
-
-      template <typename _WriteMap>
-      struct Constraints {
-	void constraints() {
-	  // No constraints for constructor.
-	  m.set(key, val);
-	  m.set(own_key, own_val);
+	  typename _ReadMap::Value own_val = m[own_key];
+	  own_val = m[own_key];
+
 	  ignore_unused_variable_warning(key);
 	  ignore_unused_variable_warning(val);
@@ -104,16 +66,52 @@
 	  ignore_unused_variable_warning(own_val);
 	}
-
-	Value& val;
-	typename _WriteMap::Value own_val;
-	Key& key;
-	typename _WriteMap::Key& own_key;
+	const Key& key;
+	const typename _ReadMap::Key& own_key;
+	const _ReadMap& m;
+      };
+
+    };
+
+
+    /// Writable map concept
+
+    /// Writable map concept.
+    ///
+    template<typename K, typename T>
+    class WriteMap
+    {
+    public:
+      /// The key type of the map.
+      typedef K Key;
+      /// The value type of the map. (The type of objects associated with the keys).
+      typedef T Value;
+
+      /// Sets the value associated with the given key.
+      void set(const Key &, const Value &) {}
+
+      /// Default constructor.
+      WriteMap() {}
+
+      template <typename _WriteMap>
+      struct Constraints {
+	void constraints() {
+	  m.set(key, val);
+	  m.set(own_key, own_val);
+
+	  ignore_unused_variable_warning(key);
+	  ignore_unused_variable_warning(val);
+	  ignore_unused_variable_warning(own_key);
+	  ignore_unused_variable_warning(own_val);
+	}
+	const Key& key;
+	const Value& val;
+	const typename _WriteMap::Key& own_key;
+	const typename _WriteMap::Value own_val;
 	_WriteMap& m;
-
       };
     };
 
     /// Read/writable map concept
-    
+
     /// Read/writable map concept.
     ///
@@ -124,12 +122,13 @@
     public:
       /// The key type of the map.
-      typedef K Key;    
-      /// The value type of the map. (The type of objects associated with the keys).
-      typedef T Value;
-
-      /// Returns the value associated with a key.
-      Value operator[](const Key &) const {return Value();}
-      /// Sets the value associated with a key.
-      void set(const Key & ,const Value &) {}
+      typedef K Key;
+      /// The value type of the map. (The type of objects associated with the keys).
+      typedef T Value;
+
+      /// Returns the value associated with the given key.
+      Value operator[](const Key &) const { return Value(); }
+
+      /// Sets the value associated with the given key.
+      void set(const Key &, const Value &) {}
 
       template<typename _ReadWriteMap>
@@ -141,11 +140,10 @@
       };
     };
-  
-  
+
+
     /// Dereferable map concept
-    
+
     /// Dereferable map concept.
     ///
-    /// \todo Rethink this concept.
     template<typename K, typename T, typename R, typename CR>
     class ReferenceMap : public ReadWriteMap<K,T>
@@ -155,5 +153,5 @@
       typedef True ReferenceMapTag;
       /// The key type of the map.
-      typedef K Key;    
+      typedef K Key;
       /// The value type of the map. (The type of objects associated with the keys).
       typedef T Value;
@@ -167,9 +165,11 @@
     public:
 
-      ///Returns a reference to the value associated with a key.
+      /// Returns a reference to the value associated with the given key.
       Reference operator[](const Key &) { return tmp; }
-      ///Returns a const reference to the value associated with a key.
+
+      /// Returns a const reference to the value associated with the given key.
       ConstReference operator[](const Key &) const { return tmp; }
-      /// Sets the value associated with a key.
+
+      /// Sets the value associated with the given key.
       void set(const Key &k,const Value &t) { operator[](k)=t; }
 
@@ -178,20 +178,23 @@
 	void constraints() {
 	  checkConcept<ReadWriteMap<K, T>, _ReferenceMap >();
+	  ref = m[key];
 	  m[key] = val;
-	  val  = m[key];
 	  m[key] = ref;
-	  ref = m[key];
+	  m[key] = cref;
+	  own_ref = m[own_key];
 	  m[own_key] = own_val;
-	  own_val  = m[own_key];
 	  m[own_key] = own_ref;
-	  own_ref = m[own_key];	  	  
-	}
-
-	typename _ReferenceMap::Key& own_key;
+	  m[own_key] = own_cref;
+	  m[key] = m[own_key];
+	  m[own_key] = m[key];
+	}
+	const Key& key;
+	Value& val;
+	Reference ref;
+	ConstReference cref;
+	const typename _ReferenceMap::Key& own_key;
 	typename _ReferenceMap::Value& own_val;
 	typename _ReferenceMap::Reference own_ref;
-	Key& key;
-	Value& val;
-	Reference ref;
+	typename _ReferenceMap::ConstReference own_cref;
 	_ReferenceMap& m;
       };
Index: lemon/maps.h
===================================================================
--- lemon/maps.h	(revision 54)
+++ lemon/maps.h	(revision 82)
@@ -25,10 +25,10 @@
 
 #include <lemon/bits/utility.h>
-// #include <lemon/bits/traits.h>
+#include <lemon/bits/traits.h>
 
 ///\file
 ///\ingroup maps
 ///\brief Miscellaneous property maps
-///
+
 #include <map>
 
@@ -40,39 +40,44 @@
   /// Base class of maps.
 
-  /// Base class of maps.
-  /// It provides the necessary <tt>typedef</tt>s required by the map concept.
-  template<typename K, typename T>
+  /// Base class of maps. It provides the necessary type definitions
+  /// required by the map %concepts.
+  template<typename K, typename V>
   class MapBase {
   public:
-    /// The key type of the map.
+    /// \biref The key type of the map.
     typedef K Key;
-    /// The value type of the map. (The type of objects associated with the keys).
-    typedef T Value;
-  };
+    /// \brief The value type of the map.
+    /// (The type of objects associated with the keys).
+    typedef V Value;
+  };
+
 
   /// Null map. (a.k.a. DoNothingMap)
 
   /// This map can be used if you have to provide a map only for
-  /// its type definitions, or if you have to provide a writable map, 
-  /// but data written to it is not required (i.e. it will be sent to 
+  /// its type definitions, or if you have to provide a writable map,
+  /// but data written to it is not required (i.e. it will be sent to
   /// <tt>/dev/null</tt>).
-  template<typename K, typename T>
-  class NullMap : public MapBase<K, T> {
-  public:
-    typedef MapBase<K, T> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-    
+  /// It conforms the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
+  ///
+  /// \sa ConstMap
+  template<typename K, typename V>
+  class NullMap : public MapBase<K, V> {
+  public:
+    typedef MapBase<K, V> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
     /// Gives back a default constructed element.
-    T operator[](const K&) const { return T(); }
+    Value operator[](const Key&) const { return Value(); }
     /// Absorbs the value.
-    void set(const K&, const T&) {}
-  };
-
-  ///Returns a \c NullMap class
-
-  ///This function just returns a \c NullMap class.
-  ///\relates NullMap
-  template <typename K, typename V> 
+    void set(const Key&, const Value&) {}
+  };
+
+  /// Returns a \ref NullMap class
+
+  /// This function just returns a \ref NullMap class.
+  /// \relates NullMap
+  template <typename K, typename V>
   NullMap<K, V> nullMap() {
     return NullMap<K, V>();
@@ -82,14 +87,22 @@
   /// Constant map.
 
-  /// This is a \ref concepts::ReadMap "readable" map which assigns a 
-  /// specified value to each key.
-  /// In other aspects it is equivalent to \c NullMap.
-  template<typename K, typename T>
-  class ConstMap : public MapBase<K, T> {
+  /// This \ref concepts::ReadMap "readable map" assigns a specified
+  /// value to each key.
+  ///
+  /// In other aspects it is equivalent to \ref NullMap.
+  /// So it conforms the \ref concepts::ReadWriteMap "ReadWriteMap"
+  /// concept, but it absorbs the data written to it.
+  ///
+  /// The simplest way of using this map is through the constMap()
+  /// function.
+  ///
+  /// \sa NullMap
+  /// \sa IdentityMap
+  template<typename K, typename V>
+  class ConstMap : public MapBase<K, V> {
   private:
-    T v;
-  public:
-
-    typedef MapBase<K, T> Parent;
+    V _value;
+  public:
+    typedef MapBase<K, V> Parent;
     typedef typename Parent::Key Key;
     typedef typename Parent::Value Value;
@@ -98,31 +111,33 @@
 
     /// Default constructor.
-    /// The value of the map will be uninitialized. 
-    /// (More exactly it will be default constructed.)
+    /// The value of the map will be default constructed.
     ConstMap() {}
-    
+
     /// Constructor with specified initial value
 
     /// Constructor with specified initial value.
-    /// \param _v is the initial value of the map.
-    ConstMap(const T &_v) : v(_v) {}
-    
-    ///\e
-    T operator[](const K&) const { return v; }
-
-    ///\e
-    void setAll(const T &t) {
-      v = t;
-    }    
-
-    template<typename T1>
-    ConstMap(const ConstMap<K, T1> &, const T &_v) : v(_v) {}
-  };
-
-  ///Returns a \c ConstMap class
-
-  ///This function just returns a \c ConstMap class.
-  ///\relates ConstMap
-  template<typename K, typename V> 
+    /// \param v is the initial value of the map.
+    ConstMap(const Value &v) : _value(v) {}
+
+    /// Gives back the specified value.
+    Value operator[](const Key&) const { return _value; }
+
+    /// Absorbs the value.
+    void set(const Key&, const Value&) {}
+
+    /// Sets the value that is assigned to each key.
+    void setAll(const Value &v) {
+      _value = v;
+    }
+
+    template<typename V1>
+    ConstMap(const ConstMap<K, V1> &, const Value &v) : _value(v) {}
+  };
+
+  /// Returns a \ref ConstMap class
+
+  /// This function just returns a \ref ConstMap class.
+  /// \relates ConstMap
+  template<typename K, typename V>
   inline ConstMap<K, V> constMap(const V &v) {
     return ConstMap<K, V>(v);
@@ -131,11 +146,20 @@
 
   template<typename T, T v>
-  struct Const { };
+  struct Const {};
 
   /// Constant map with inlined constant value.
 
-  /// This is a \ref concepts::ReadMap "readable" map which assigns a 
-  /// specified value to each key.
-  /// In other aspects it is equivalent to \c NullMap.
+  /// This \ref concepts::ReadMap "readable map" assigns a specified
+  /// value to each key.
+  ///
+  /// In other aspects it is equivalent to \ref NullMap.
+  /// So it conforms the \ref concepts::ReadWriteMap "ReadWriteMap"
+  /// concept, but it absorbs the data written to it.
+  ///
+  /// The simplest way of using this map is through the constMap()
+  /// function.
+  ///
+  /// \sa NullMap
+  /// \sa IdentityMap
   template<typename K, typename V, V v>
   class ConstMap<K, Const<V, v> > : public MapBase<K, V> {
@@ -145,67 +169,228 @@
     typedef typename Parent::Value Value;
 
-    ConstMap() { }
-    ///\e
-    V operator[](const K&) const { return v; }
-    ///\e
-    void set(const K&, const V&) { }
-  };
-
-  ///Returns a \c ConstMap class with inlined value
-
-  ///This function just returns a \c ConstMap class with inlined value.
-  ///\relates ConstMap
-  template<typename K, typename V, V v> 
+    /// Constructor.
+    ConstMap() {}
+
+    /// Gives back the specified value.
+    Value operator[](const Key&) const { return v; }
+
+    /// Absorbs the value.
+    void set(const Key&, const Value&) {}
+  };
+
+  /// Returns a \ref ConstMap class with inlined constant value
+
+  /// This function just returns a \ref ConstMap class with inlined
+  /// constant value.
+  /// \relates ConstMap
+  template<typename K, typename V, V v>
   inline ConstMap<K, Const<V, v> > constMap() {
     return ConstMap<K, Const<V, v> >();
   }
 
-  ///Map based on \c std::map
-
-  ///This is essentially a wrapper for \c std::map with addition that
-  ///you can specify a default value different from \c Value().
-  ///It meets the \ref concepts::ReferenceMap "ReferenceMap" concept.
-  template <typename K, typename T, typename Compare = std::less<K> >
-  class StdMap : public MapBase<K, T> {
-    template <typename K1, typename T1, typename C1>
-    friend class StdMap;
-  public:
-
-    typedef MapBase<K, T> Parent;
-    ///Key type
-    typedef typename Parent::Key Key;
-    ///Value type
-    typedef typename Parent::Value Value;
-    ///Reference Type
-    typedef T& Reference;
-    ///Const reference type
-    typedef const T& ConstReference;
+
+  /// Identity map.
+
+  /// This \ref concepts::ReadMap "read-only map" gives back the given
+  /// key as value without any modification.
+  ///
+  /// \sa ConstMap
+  template <typename T>
+  class IdentityMap : public MapBase<T, T> {
+  public:
+    typedef MapBase<T, T> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Gives back the given value without any modification.
+    Value operator[](const Key &k) const {
+      return k;
+    }
+  };
+
+  /// Returns an \ref IdentityMap class
+
+  /// This function just returns an \ref IdentityMap class.
+  /// \relates IdentityMap
+  template<typename T>
+  inline IdentityMap<T> identityMap() {
+    return IdentityMap<T>();
+  }
+
+
+  /// \brief Map for storing values for integer keys from the range
+  /// <tt>[0..size-1]</tt>.
+  ///
+  /// This map is essentially a wrapper for \c std::vector. It assigns
+  /// values to integer keys from the range <tt>[0..size-1]</tt>.
+  /// It can be used with some data structures, for example
+  /// \ref UnionFind, \ref BinHeap, when the used items are small
+  /// integers. This map conforms the \ref concepts::ReferenceMap
+  /// "ReferenceMap" concept.
+  ///
+  /// The simplest way of using this map is through the rangeMap()
+  /// function.
+  template <typename V>
+  class RangeMap : public MapBase<int, V> {
+    template <typename V1>
+    friend class RangeMap;
+  private:
+
+    typedef std::vector<V> Vector;
+    Vector _vector;
+
+  public:
+
+    typedef MapBase<int, V> Parent;
+    /// Key type
+    typedef typename Parent::Key Key;
+    /// Value type
+    typedef typename Parent::Value Value;
+    /// Reference type
+    typedef typename Vector::reference Reference;
+    /// Const reference type
+    typedef typename Vector::const_reference ConstReference;
 
     typedef True ReferenceMapTag;
 
+  public:
+
+    /// Constructor with specified default value.
+    RangeMap(int size = 0, const Value &value = Value())
+      : _vector(size, value) {}
+
+    /// Constructs the map from an appropriate \c std::vector.
+    template <typename V1>
+    RangeMap(const std::vector<V1>& vector)
+      : _vector(vector.begin(), vector.end()) {}
+
+    /// Constructs the map from another \ref RangeMap.
+    template <typename V1>
+    RangeMap(const RangeMap<V1> &c)
+      : _vector(c._vector.begin(), c._vector.end()) {}
+
+    /// Returns the size of the map.
+    int size() {
+      return _vector.size();
+    }
+
+    /// Resizes the map.
+
+    /// Resizes the underlying \c std::vector container, so changes the
+    /// keyset of the map.
+    /// \param size The new size of the map. The new keyset will be the
+    /// range <tt>[0..size-1]</tt>.
+    /// \param value The default value to assign to the new keys.
+    void resize(int size, const Value &value = Value()) {
+      _vector.resize(size, value);
+    }
+
   private:
-    
-    typedef std::map<K, T, Compare> Map;
+
+    RangeMap& operator=(const RangeMap&);
+
+  public:
+
+    ///\e
+    Reference operator[](const Key &k) {
+      return _vector[k];
+    }
+
+    ///\e
+    ConstReference operator[](const Key &k) const {
+      return _vector[k];
+    }
+
+    ///\e
+    void set(const Key &k, const Value &v) {
+      _vector[k] = v;
+    }
+  };
+
+  /// Returns a \ref RangeMap class
+
+  /// This function just returns a \ref RangeMap class.
+  /// \relates RangeMap
+  template<typename V>
+  inline RangeMap<V> rangeMap(int size = 0, const V &value = V()) {
+    return RangeMap<V>(size, value);
+  }
+
+  /// \brief Returns a \ref RangeMap class created from an appropriate
+  /// \c std::vector
+
+  /// This function just returns a \ref RangeMap class created from an
+  /// appropriate \c std::vector.
+  /// \relates RangeMap
+  template<typename V>
+  inline RangeMap<V> rangeMap(const std::vector<V> &vector) {
+    return RangeMap<V>(vector);
+  }
+
+
+  /// Map type based on \c std::map
+
+  /// This map is essentially a wrapper for \c std::map with addition
+  /// that you can specify a default value for the keys that are not
+  /// stored actually. This value can be different from the default
+  /// contructed value (i.e. \c %Value()).
+  /// This type conforms the \ref concepts::ReferenceMap "ReferenceMap"
+  /// concept.
+  ///
+  /// This map is useful if a default value should be assigned to most of
+  /// the keys and different values should be assigned only to a few
+  /// keys (i.e. the map is "sparse").
+  /// The name of this type also refers to this important usage.
+  ///
+  /// Apart form that this map can be used in many other cases since it
+  /// is based on \c std::map, which is a general associative container.
+  /// However keep in mind that it is usually not as efficient as other
+  /// maps.
+  ///
+  /// The simplest way of using this map is through the sparseMap()
+  /// function.
+  template <typename K, typename V, typename Compare = std::less<K> >
+  class SparseMap : public MapBase<K, V> {
+    template <typename K1, typename V1, typename C1>
+    friend class SparseMap;
+  public:
+
+    typedef MapBase<K, V> Parent;
+    /// Key type
+    typedef typename Parent::Key Key;
+    /// Value type
+    typedef typename Parent::Value Value;
+    /// Reference type
+    typedef Value& Reference;
+    /// Const reference type
+    typedef const Value& ConstReference;
+
+    typedef True ReferenceMapTag;
+
+  private:
+
+    typedef std::map<K, V, Compare> Map;
+    Map _map;
     Value _value;
-    Map _map;
-
-  public:
-
-    /// Constructor with specified default value
-    StdMap(const T& value = T()) : _value(value) {}
-    /// \brief Constructs the map from an appropriate \c std::map, and 
+
+  public:
+
+    /// \brief Constructor with specified default value.
+    SparseMap(const Value &value = Value()) : _value(value) {}
+    /// \brief Constructs the map from an appropriate \c std::map, and
     /// explicitly specifies a default value.
-    template <typename T1, typename Comp1>
-    StdMap(const std::map<Key, T1, Comp1> &map, const T& value = T()) 
+    template <typename V1, typename Comp1>
+    SparseMap(const std::map<Key, V1, Comp1> &map,
+              const Value &value = Value())
       : _map(map.begin(), map.end()), _value(value) {}
-    
-    /// \brief Constructs a map from an other \ref StdMap.
-    template<typename T1, typename Comp1>
-    StdMap(const StdMap<Key, T1, Comp1> &c) 
+
+    /// \brief Constructs the map from another \ref SparseMap.
+    template<typename V1, typename Comp1>
+    SparseMap(const SparseMap<Key, V1, Comp1> &c)
       : _map(c._map.begin(), c._map.end()), _value(c._value) {}
 
   private:
 
-    StdMap& operator=(const StdMap&);
+    SparseMap& operator=(const SparseMap&);
 
   public:
@@ -220,5 +405,5 @@
     }
 
-    /// \e 
+    ///\e
     ConstReference operator[](const Key &k) const {
       typename Map::const_iterator it = _map.find(k);
@@ -229,147 +414,46 @@
     }
 
-    /// \e 
-    void set(const Key &k, const T &t) {
+    ///\e
+    void set(const Key &k, const Value &v) {
       typename Map::iterator it = _map.lower_bound(k);
       if (it != _map.end() && !_map.key_comp()(k, it->first))
-	it->second = t;
+	it->second = v;
       else
-	_map.insert(it, std::make_pair(k, t));
+	_map.insert(it, std::make_pair(k, v));
     }
 
-    /// \e
-    void setAll(const T &t) {
-      _value = t;
+    ///\e
+    void setAll(const Value &v) {
+      _value = v;
       _map.clear();
-    }    
-
-  };
-  
-  ///Returns a \c StdMap class
-
-  ///This function just returns a \c StdMap class with specified 
-  ///default value.
-  ///\relates StdMap
-  template<typename K, typename V, typename Compare> 
-  inline StdMap<K, V, Compare> stdMap(const V& value = V()) {
-    return StdMap<K, V, Compare>(value);
-  }
-  
-  ///Returns a \c StdMap class
-
-  ///This function just returns a \c StdMap class with specified 
-  ///default value.
-  ///\relates StdMap
-  template<typename K, typename V> 
-  inline StdMap<K, V, std::less<K> > stdMap(const V& value = V()) {
-    return StdMap<K, V, std::less<K> >(value);
-  }
-  
-  ///Returns a \c StdMap class created from an appropriate std::map
-
-  ///This function just returns a \c StdMap class created from an 
-  ///appropriate std::map.
-  ///\relates StdMap
-  template<typename K, typename V, typename Compare> 
-  inline StdMap<K, V, Compare> stdMap( const std::map<K, V, Compare> &map, 
-                                       const V& value = V() ) {
-    return StdMap<K, V, Compare>(map, value);
-  }
-
-  ///Returns a \c StdMap class created from an appropriate std::map
-
-  ///This function just returns a \c StdMap class created from an 
-  ///appropriate std::map.
-  ///\relates StdMap
-  template<typename K, typename V> 
-  inline StdMap<K, V, std::less<K> > stdMap( const std::map<K, V, std::less<K> > &map, 
-                                             const V& value = V() ) {
-    return StdMap<K, V, std::less<K> >(map, value);
-  }
-
-  /// \brief Map for storing values for keys from the range <tt>[0..size-1]</tt>
-  ///
-  /// This map has the <tt>[0..size-1]</tt> keyset and the values
-  /// are stored in a \c std::vector<T>  container. It can be used with
-  /// some data structures, for example \c UnionFind, \c BinHeap, when 
-  /// the used items are small integer numbers.
-  /// This map meets the \ref concepts::ReferenceMap "ReferenceMap" concept.
-  ///
-  /// \todo Revise its name
-  template <typename T>
-  class IntegerMap : public MapBase<int, T> {
-
-    template <typename T1>
-    friend class IntegerMap;
-
-  public:
-
-    typedef MapBase<int, T> Parent;
-    ///\e
-    typedef typename Parent::Key Key;
-    ///\e
-    typedef typename Parent::Value Value;
-    ///\e
-    typedef T& Reference;
-    ///\e
-    typedef const T& ConstReference;
-
-    typedef True ReferenceMapTag;
-
-  private:
-    
-    typedef std::vector<T> Vector;
-    Vector _vector;
-
-  public:
-
-    /// Constructor with specified default value
-    IntegerMap(int size = 0, const T& value = T()) : _vector(size, value) {}
-
-    /// \brief Constructs the map from an appropriate \c std::vector.
-    template <typename T1>
-    IntegerMap(const std::vector<T1>& vector) 
-      : _vector(vector.begin(), vector.end()) {}
-    
-    /// \brief Constructs a map from an other \ref IntegerMap.
-    template <typename T1>
-    IntegerMap(const IntegerMap<T1> &c) 
-      : _vector(c._vector.begin(), c._vector.end()) {}
-
-    /// \brief Resize the container
-    void resize(int size, const T& value = T()) {
-      _vector.resize(size, value);
     }
-
-  private:
-
-    IntegerMap& operator=(const IntegerMap&);
-
-  public:
-
-    ///\e
-    Reference operator[](Key k) {
-      return _vector[k];
-    }
-
-    /// \e 
-    ConstReference operator[](Key k) const {
-      return _vector[k];
-    }
-
-    /// \e 
-    void set(const Key &k, const T& t) {
-      _vector[k] = t;
-    }
-
-  };
-  
-  ///Returns an \c IntegerMap class
-
-  ///This function just returns an \c IntegerMap class.
-  ///\relates IntegerMap
-  template<typename T>
-  inline IntegerMap<T> integerMap(int size = 0, const T& value = T()) {
-    return IntegerMap<T>(size, value);
+  };
+
+  /// Returns a \ref SparseMap class
+
+  /// This function just returns a \ref SparseMap class with specified
+  /// default value.
+  /// \relates SparseMap
+  template<typename K, typename V, typename Compare>
+  inline SparseMap<K, V, Compare> sparseMap(const V& value = V()) {
+    return SparseMap<K, V, Compare>(value);
+  }
+
+  template<typename K, typename V>
+  inline SparseMap<K, V, std::less<K> > sparseMap(const V& value = V()) {
+    return SparseMap<K, V, std::less<K> >(value);
+  }
+
+  /// \brief Returns a \ref SparseMap class created from an appropriate
+  /// \c std::map
+
+  /// This function just returns a \ref SparseMap class created from an
+  /// appropriate \c std::map.
+  /// \relates SparseMap
+  template<typename K, typename V, typename Compare>
+  inline SparseMap<K, V, Compare>
+    sparseMap(const std::map<K, V, Compare> &map, const V& value = V())
+  {
+    return SparseMap<K, V, Compare>(map, value);
   }
 
@@ -379,78 +463,210 @@
   /// @{
 
-  /// \brief Identity map.
-  ///
-  /// This map gives back the given key as value without any
-  /// modification. 
-  template <typename T>
-  class IdentityMap : public MapBase<T, T> {
-  public:
-    typedef MapBase<T, T> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    /// \e
-    const T& operator[](const T& t) const {
-      return t;
-    }
-  };
-
-  ///Returns an \c IdentityMap class
-
-  ///This function just returns an \c IdentityMap class.
-  ///\relates IdentityMap
-  template<typename T>
-  inline IdentityMap<T> identityMap() {
-    return IdentityMap<T>();
-  }
-  
-
-  ///\brief Convert the \c Value of a map to another type using
-  ///the default conversion.
-  ///
-  ///This \ref concepts::ReadMap "read only map"
-  ///converts the \c Value of a map to type \c T.
-  ///Its \c Key is inherited from \c M.
-  template <typename M, typename T> 
-  class ConvertMap : public MapBase<typename M::Key, T> {
-    const M& m;
-  public:
-    typedef MapBase<typename M::Key, T> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-
-    ///Constructor.
-    ///\param _m is the underlying map.
-    ConvertMap(const M &_m) : m(_m) {};
-
-    ///\e
-    Value operator[](const Key& k) const {return m[k];}
-  };
-  
-  ///Returns a \c ConvertMap class
-
-  ///This function just returns a \c ConvertMap class.
-  ///\relates ConvertMap
-  template<typename T, typename M>
-  inline ConvertMap<M, T> convertMap(const M &m) {
-    return ConvertMap<M, T>(m);
-  }
-
-  ///Simple wrapping of a map
-
-  ///This \ref concepts::ReadMap "read only map" returns the simple
-  ///wrapping of the given map. Sometimes the reference maps cannot be
-  ///combined with simple read maps. This map adaptor wraps the given
-  ///map to simple read map.
-  ///
-  ///\sa SimpleWriteMap
-  ///
-  /// \todo Revise the misleading name 
-  template<typename M> 
-  class SimpleMap : public MapBase<typename M::Key, typename M::Value> {
-    const M& m;
-
+  /// Composition of two maps
+
+  /// This \ref concepts::ReadMap "read-only map" returns the
+  /// composition of two given maps. That is to say, if \c m1 is of
+  /// type \c M1 and \c m2 is of \c M2, then for
+  /// \code
+  ///   ComposeMap<M1, M2> cm(m1,m2);
+  /// \endcode
+  /// <tt>cm[x]</tt> will be equal to <tt>m1[m2[x]]</tt>.
+  ///
+  /// The \c Key type of the map is inherited from \c M2 and the
+  /// \c Value type is from \c M1.
+  /// \c M2::Value must be convertible to \c M1::Key.
+  ///
+  /// The simplest way of using this map is through the composeMap()
+  /// function.
+  ///
+  /// \sa CombineMap
+  ///
+  /// \todo Check the requirements.
+  template <typename M1, typename M2>
+  class ComposeMap : public MapBase<typename M2::Key, typename M1::Value> {
+    const M1 &_m1;
+    const M2 &_m2;
+  public:
+    typedef MapBase<typename M2::Key, typename M1::Value> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+    ComposeMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
+
+    /// \e
+    typename MapTraits<M1>::ConstReturnValue
+    operator[](const Key &k) const { return _m1[_m2[k]]; }
+  };
+
+  /// Returns a \ref ComposeMap class
+
+  /// This function just returns a \ref ComposeMap class.
+  ///
+  /// If \c m1 and \c m2 are maps and the \c Value type of \c m2 is
+  /// convertible to the \c Key of \c m1, then <tt>composeMap(m1,m2)[x]</tt>
+  /// will be equal to <tt>m1[m2[x]]</tt>.
+  ///
+  /// \relates ComposeMap
+  template <typename M1, typename M2>
+  inline ComposeMap<M1, M2> composeMap(const M1 &m1, const M2 &m2) {
+    return ComposeMap<M1, M2>(m1, m2);
+  }
+
+
+  /// Combination of two maps using an STL (binary) functor.
+
+  /// This \ref concepts::ReadMap "read-only map" takes two maps and a
+  /// binary functor and returns the combination of the two given maps
+  /// using the functor.
+  /// That is to say, if \c m1 is of type \c M1 and \c m2 is of \c M2
+  /// and \c f is of \c F, then for
+  /// \code
+  ///   CombineMap<M1,M2,F,V> cm(m1,m2,f);
+  /// \endcode
+  /// <tt>cm[x]</tt> will be equal to <tt>f(m1[x],m2[x])</tt>.
+  ///
+  /// The \c Key type of the map is inherited from \c M1 (\c M1::Key
+  /// must be convertible to \c M2::Key) and the \c Value type is \c V.
+  /// \c M2::Value and \c M1::Value must be convertible to the
+  /// corresponding input parameter of \c F and the return type of \c F
+  /// must be convertible to \c V.
+  ///
+  /// The simplest way of using this map is through the combineMap()
+  /// function.
+  ///
+  /// \sa ComposeMap
+  ///
+  /// \todo Check the requirements.
+  template<typename M1, typename M2, typename F,
+	   typename V = typename F::result_type>
+  class CombineMap : public MapBase<typename M1::Key, V> {
+    const M1 &_m1;
+    const M2 &_m2;
+    F _f;
+  public:
+    typedef MapBase<typename M1::Key, V> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+    CombineMap(const M1 &m1, const M2 &m2, const F &f = F())
+      : _m1(m1), _m2(m2), _f(f) {}
+    /// \e
+    Value operator[](const Key &k) const { return _f(_m1[k],_m2[k]); }
+  };
+
+  /// Returns a \ref CombineMap class
+
+  /// This function just returns a \ref CombineMap class.
+  ///
+  /// For example, if \c m1 and \c m2 are both maps with \c double
+  /// values, then
+  /// \code
+  ///   combineMap(m1,m2,std::plus<double>())
+  /// \endcode
+  /// is equivalent to
+  /// \code
+  ///   addMap(m1,m2)
+  /// \endcode
+  ///
+  /// This function is specialized for adaptable binary function
+  /// classes and C++ functions.
+  ///
+  /// \relates CombineMap
+  template<typename M1, typename M2, typename F, typename V>
+  inline CombineMap<M1, M2, F, V>
+  combineMap(const M1 &m1, const M2 &m2, const F &f) {
+    return CombineMap<M1, M2, F, V>(m1,m2,f);
+  }
+
+  template<typename M1, typename M2, typename F>
+  inline CombineMap<M1, M2, F, typename F::result_type>
+  combineMap(const M1 &m1, const M2 &m2, const F &f) {
+    return combineMap<M1, M2, F, typename F::result_type>(m1,m2,f);
+  }
+
+  template<typename M1, typename M2, typename K1, typename K2, typename V>
+  inline CombineMap<M1, M2, V (*)(K1, K2), V>
+  combineMap(const M1 &m1, const M2 &m2, V (*f)(K1, K2)) {
+    return combineMap<M1, M2, V (*)(K1, K2), V>(m1,m2,f);
+  }
+
+
+  /// Converts an STL style (unary) functor to a map
+
+  /// This \ref concepts::ReadMap "read-only map" returns the value
+  /// of a given functor. Actually, it just wraps the functor and
+  /// provides the \c Key and \c Value typedefs.
+  ///
+  /// Template parameters \c K and \c V will become its \c Key and
+  /// \c Value. In most cases they have to be given explicitly because
+  /// a functor typically does not provide \c argument_type and
+  /// \c result_type typedefs.
+  /// Parameter \c F is the type of the used functor.
+  ///
+  /// The simplest way of using this map is through the functorToMap()
+  /// function.
+  ///
+  /// \sa MapToFunctor
+  template<typename F,
+	   typename K = typename F::argument_type,
+	   typename V = typename F::result_type>
+  class FunctorToMap : public MapBase<K, V> {
+    const F &_f;
+  public:
+    typedef MapBase<K, V> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+    FunctorToMap(const F &f = F()) : _f(f) {}
+    /// \e
+    Value operator[](const Key &k) const { return _f(k); }
+  };
+
+  /// Returns a \ref FunctorToMap class
+
+  /// This function just returns a \ref FunctorToMap class.
+  ///
+  /// This function is specialized for adaptable binary function
+  /// classes and C++ functions.
+  ///
+  /// \relates FunctorToMap
+  template<typename K, typename V, typename F>
+  inline FunctorToMap<F, K, V> functorToMap(const F &f) {
+    return FunctorToMap<F, K, V>(f);
+  }
+
+  template <typename F>
+  inline FunctorToMap<F, typename F::argument_type, typename F::result_type>
+    functorToMap(const F &f)
+  {
+    return FunctorToMap<F, typename F::argument_type,
+      typename F::result_type>(f);
+  }
+
+  template <typename K, typename V>
+  inline FunctorToMap<V (*)(K), K, V> functorToMap(V (*f)(K)) {
+    return FunctorToMap<V (*)(K), K, V>(f);
+  }
+
+
+  /// Converts a map to an STL style (unary) functor
+
+  /// This class converts a map to an STL style (unary) functor.
+  /// That is it provides an <tt>operator()</tt> to read its values.
+  ///
+  /// For the sake of convenience it also works as a usual
+  /// \ref concepts::ReadMap "readable map", i.e. <tt>operator[]</tt>
+  /// and the \c Key and \c Value typedefs also exist.
+  ///
+  /// The simplest way of using this map is through the mapToFunctor()
+  /// function.
+  ///
+  ///\sa FunctorToMap
+  template <typename M>
+  class MapToFunctor : public MapBase<typename M::Key, typename M::Value> {
+    const M &_m;
   public:
     typedef MapBase<typename M::Key, typename M::Value> Parent;
@@ -458,66 +674,127 @@
     typedef typename Parent::Value Value;
 
-    ///Constructor
-    SimpleMap(const M &_m) : m(_m) {};
-    ///\e
-    Value operator[](Key k) const {return m[k];}
-  };
-  
-  ///Returns a \c SimpleMap class
-
-  ///This function just returns a \c SimpleMap class.
-  ///\relates SimpleMap
+    typedef typename Parent::Key argument_type;
+    typedef typename Parent::Value result_type;
+
+    /// Constructor
+    MapToFunctor(const M &m) : _m(m) {}
+    /// \e
+    Value operator()(const Key &k) const { return _m[k]; }
+    /// \e
+    Value operator[](const Key &k) const { return _m[k]; }
+  };
+
+  /// Returns a \ref MapToFunctor class
+
+  /// This function just returns a \ref MapToFunctor class.
+  /// \relates MapToFunctor
   template<typename M>
-  inline SimpleMap<M> simpleMap(const M &m) {
-    return SimpleMap<M>(m);
-  }
-
-  ///Simple writable wrapping of a map
-
-  ///This \ref concepts::ReadWriteMap "read-write map" returns the simple
-  ///wrapping of the given map. Sometimes the reference maps cannot be
-  ///combined with simple read-write maps. This map adaptor wraps the
-  ///given map to simple read-write map.
-  ///
-  ///\sa SimpleMap
-  ///
-  /// \todo Revise the misleading name
-  template<typename M> 
-  class SimpleWriteMap : public MapBase<typename M::Key, typename M::Value> {
-    M& m;
-
-  public:
-    typedef MapBase<typename M::Key, typename M::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-    SimpleWriteMap(M &_m) : m(_m) {};
-    ///\e
-    Value operator[](Key k) const {return m[k];}
-    ///\e
-    void set(Key k, const Value& c) { m.set(k, c); }
-  };
-
-  ///Returns a \c SimpleWriteMap class
-
-  ///This function just returns a \c SimpleWriteMap class.
-  ///\relates SimpleWriteMap
-  template<typename M>
-  inline SimpleWriteMap<M> simpleWriteMap(M &m) {
-    return SimpleWriteMap<M>(m);
-  }
-
-  ///Sum of two maps
-
-  ///This \ref concepts::ReadMap "read only map" returns the sum of the two
-  ///given maps.
-  ///Its \c Key and \c Value are inherited from \c M1.
-  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
-  template<typename M1, typename M2> 
+  inline MapToFunctor<M> mapToFunctor(const M &m) {
+    return MapToFunctor<M>(m);
+  }
+
+
+  /// \brief Map adaptor to convert the \c Value type of a map to
+  /// another type using the default conversion.
+
+  /// Map adaptor to convert the \c Value type of a \ref concepts::ReadMap
+  /// "readable map" to another type using the default conversion.
+  /// The \c Key type of it is inherited from \c M and the \c Value
+  /// type is \c V.
+  /// This type conforms the \ref concepts::ReadMap "ReadMap" concept.
+  ///
+  /// The simplest way of using this map is through the convertMap()
+  /// function.
+  template <typename M, typename V>
+  class ConvertMap : public MapBase<typename M::Key, V> {
+    const M &_m;
+  public:
+    typedef MapBase<typename M::Key, V> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+
+    /// Constructor.
+    /// \param m The underlying map.
+    ConvertMap(const M &m) : _m(m) {}
+
+    /// \e
+    Value operator[](const Key &k) const { return _m[k]; }
+  };
+
+  /// Returns a \ref ConvertMap class
+
+  /// This function just returns a \ref ConvertMap class.
+  /// \relates ConvertMap
+  template<typename V, typename M>
+  inline ConvertMap<M, V> convertMap(const M &map) {
+    return ConvertMap<M, V>(map);
+  }
+
+
+  /// Applies all map setting operations to two maps
+
+  /// This map has two \ref concepts::WriteMap "writable map" parameters
+  /// and each write request will be passed to both of them.
+  /// If \c M1 is also \ref concepts::ReadMap "readable", then the read
+  /// operations will return the corresponding values of \c M1.
+  ///
+  /// The \c Key and \c Value types are inherited from \c M1.
+  /// The \c Key and \c Value of \c M2 must be convertible from those
+  /// of \c M1.
+  ///
+  /// The simplest way of using this map is through the forkMap()
+  /// function.
+  template<typename  M1, typename M2>
+  class ForkMap : public MapBase<typename M1::Key, typename M1::Value> {
+    M1 &_m1;
+    M2 &_m2;
+  public:
+    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+    ForkMap(M1 &m1, M2 &m2) : _m1(m1), _m2(m2) {}
+    /// Returns the value associated with the given key in the first map.
+    Value operator[](const Key &k) const { return _m1[k]; }
+    /// Sets the value associated with the given key in both maps.
+    void set(const Key &k, const Value &v) { _m1.set(k,v); _m2.set(k,v); }
+  };
+
+  /// Returns a \ref ForkMap class
+
+  /// This function just returns a \ref ForkMap class.
+  /// \relates ForkMap
+  template <typename M1, typename M2>
+  inline ForkMap<M1,M2> forkMap(M1 &m1, M2 &m2) {
+    return ForkMap<M1,M2>(m1,m2);
+  }
+
+
+  /// Sum of two maps
+
+  /// This \ref concepts::ReadMap "read-only map" returns the sum
+  /// of the values of the two given maps.
+  /// Its \c Key and \c Value types are inherited from \c M1.
+  /// The \c Key and \c Value of \c M2 must be convertible to those of
+  /// \c M1.
+  ///
+  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
+  /// \code
+  ///   AddMap<M1,M2> am(m1,m2);
+  /// \endcode
+  /// <tt>am[x]</tt> will be equal to <tt>m1[x]+m2[x]</tt>.
+  ///
+  /// The simplest way of using this map is through the addMap()
+  /// function.
+  ///
+  /// \sa SubMap, MulMap, DivMap
+  /// \sa ShiftMap, ShiftWriteMap
+  template<typename M1, typename M2>
   class AddMap : public MapBase<typename M1::Key, typename M1::Value> {
-    const M1& m1;
-    const M2& m2;
-
+    const M1 &_m1;
+    const M2 &_m2;
   public:
     typedef MapBase<typename M1::Key, typename M1::Value> Parent;
@@ -525,115 +802,47 @@
     typedef typename Parent::Value Value;
 
-    ///Constructor
-    AddMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
-    ///\e
-    Value operator[](Key k) const {return m1[k]+m2[k];}
-  };
-  
-  ///Returns an \c AddMap class
-
-  ///This function just returns an \c AddMap class.
-  ///\todo Extend the documentation: how to call these type of functions?
-  ///
-  ///\relates AddMap
-  template<typename M1, typename M2> 
-  inline AddMap<M1, M2> addMap(const M1 &m1,const M2 &m2) {
+    /// Constructor
+    AddMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m1[k]+_m2[k]; }
+  };
+
+  /// Returns an \ref AddMap class
+
+  /// This function just returns an \ref AddMap class.
+  ///
+  /// For example, if \c m1 and \c m2 are both maps with \c double
+  /// values, then <tt>addMap(m1,m2)[x]</tt> will be equal to
+  /// <tt>m1[x]+m2[x]</tt>.
+  ///
+  /// \relates AddMap
+  template<typename M1, typename M2>
+  inline AddMap<M1, M2> addMap(const M1 &m1, const M2 &m2) {
     return AddMap<M1, M2>(m1,m2);
   }
 
-  ///Shift a map with a constant.
-
-  ///This \ref concepts::ReadMap "read only map" returns the sum of the
-  ///given map and a constant value.
-  ///Its \c Key and \c Value are inherited from \c M.
-  ///
-  ///Actually,
-  ///\code
-  ///  ShiftMap<X> sh(x,v);
-  ///\endcode
-  ///is equivalent to
-  ///\code
-  ///  ConstMap<X::Key, X::Value> c_tmp(v);
-  ///  AddMap<X, ConstMap<X::Key, X::Value> > sh(x,v);
-  ///\endcode
-  ///
-  ///\sa ShiftWriteMap
-  template<typename M, typename C = typename M::Value> 
-  class ShiftMap : public MapBase<typename M::Key, typename M::Value> {
-    const M& m;
-    C v;
-  public:
-    typedef MapBase<typename M::Key, typename M::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-
-    ///Constructor.
-    ///\param _m is the undelying map.
-    ///\param _v is the shift value.
-    ShiftMap(const M &_m, const C &_v ) : m(_m), v(_v) {};
-    ///\e
-    Value operator[](Key k) const {return m[k] + v;}
-  };
-
-  ///Shift a map with a constant (ReadWrite version).
-
-  ///This \ref concepts::ReadWriteMap "read-write map" returns the sum of the
-  ///given map and a constant value. It makes also possible to write the map.
-  ///Its \c Key and \c Value are inherited from \c M.
-  ///
-  ///\sa ShiftMap
-  template<typename M, typename C = typename M::Value> 
-  class ShiftWriteMap : public MapBase<typename M::Key, typename M::Value> {
-    M& m;
-    C v;
-  public:
-    typedef MapBase<typename M::Key, typename M::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-
-    ///Constructor.
-    ///\param _m is the undelying map.
-    ///\param _v is the shift value.
-    ShiftWriteMap(M &_m, const C &_v ) : m(_m), v(_v) {};
-    /// \e
-    Value operator[](Key k) const {return m[k] + v;}
-    /// \e
-    void set(Key k, const Value& c) { m.set(k, c - v); }
-  };
-  
-  ///Returns a \c ShiftMap class
-
-  ///This function just returns a \c ShiftMap class.
-  ///\relates ShiftMap
-  template<typename M, typename C> 
-  inline ShiftMap<M, C> shiftMap(const M &m,const C &v) {
-    return ShiftMap<M, C>(m,v);
-  }
-
-  ///Returns a \c ShiftWriteMap class
-
-  ///This function just returns a \c ShiftWriteMap class.
-  ///\relates ShiftWriteMap
-  template<typename M, typename C> 
-  inline ShiftWriteMap<M, C> shiftMap(M &m,const C &v) {
-    return ShiftWriteMap<M, C>(m,v);
-  }
-
-  ///Difference of two maps
-
-  ///This \ref concepts::ReadMap "read only map" returns the difference
-  ///of the values of the two given maps.
-  ///Its \c Key and \c Value are inherited from \c M1.
-  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
-  ///
-  /// \todo Revise the misleading name
-  template<typename M1, typename M2> 
+
+  /// Difference of two maps
+
+  /// This \ref concepts::ReadMap "read-only map" returns the difference
+  /// of the values of the two given maps.
+  /// Its \c Key and \c Value types are inherited from \c M1.
+  /// The \c Key and \c Value of \c M2 must be convertible to those of
+  /// \c M1.
+  ///
+  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
+  /// \code
+  ///   SubMap<M1,M2> sm(m1,m2);
+  /// \endcode
+  /// <tt>sm[x]</tt> will be equal to <tt>m1[x]-m2[x]</tt>.
+  ///
+  /// The simplest way of using this map is through the subMap()
+  /// function.
+  ///
+  /// \sa AddMap, MulMap, DivMap
+  template<typename M1, typename M2>
   class SubMap : public MapBase<typename M1::Key, typename M1::Value> {
-    const M1& m1;
-    const M2& m2;
+    const M1 &_m1;
+    const M2 &_m2;
   public:
     typedef MapBase<typename M1::Key, typename M1::Value> Parent;
@@ -641,30 +850,48 @@
     typedef typename Parent::Value Value;
 
-    ///Constructor
-    SubMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
-    /// \e
-    Value operator[](Key k) const {return m1[k]-m2[k];}
-  };
-  
-  ///Returns a \c SubMap class
-
-  ///This function just returns a \c SubMap class.
-  ///
-  ///\relates SubMap
-  template<typename M1, typename M2> 
+    /// Constructor
+    SubMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m1[k]-_m2[k]; }
+  };
+
+  /// Returns a \ref SubMap class
+
+  /// This function just returns a \ref SubMap class.
+  ///
+  /// For example, if \c m1 and \c m2 are both maps with \c double
+  /// values, then <tt>subMap(m1,m2)[x]</tt> will be equal to
+  /// <tt>m1[x]-m2[x]</tt>.
+  ///
+  /// \relates SubMap
+  template<typename M1, typename M2>
   inline SubMap<M1, M2> subMap(const M1 &m1, const M2 &m2) {
-    return SubMap<M1, M2>(m1, m2);
-  }
-
-  ///Product of two maps
-
-  ///This \ref concepts::ReadMap "read only map" returns the product of the
-  ///values of the two given maps.
-  ///Its \c Key and \c Value are inherited from \c M1.
-  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
-  template<typename M1, typename M2> 
+    return SubMap<M1, M2>(m1,m2);
+  }
+
+
+  /// Product of two maps
+
+  /// This \ref concepts::ReadMap "read-only map" returns the product
+  /// of the values of the two given maps.
+  /// Its \c Key and \c Value types are inherited from \c M1.
+  /// The \c Key and \c Value of \c M2 must be convertible to those of
+  /// \c M1.
+  ///
+  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
+  /// \code
+  ///   MulMap<M1,M2> mm(m1,m2);
+  /// \endcode
+  /// <tt>mm[x]</tt> will be equal to <tt>m1[x]*m2[x]</tt>.
+  ///
+  /// The simplest way of using this map is through the mulMap()
+  /// function.
+  ///
+  /// \sa AddMap, SubMap, DivMap
+  /// \sa ScaleMap, ScaleWriteMap
+  template<typename M1, typename M2>
   class MulMap : public MapBase<typename M1::Key, typename M1::Value> {
-    const M1& m1;
-    const M2& m2;
+    const M1 &_m1;
+    const M2 &_m2;
   public:
     typedef MapBase<typename M1::Key, typename M1::Value> Parent;
@@ -672,113 +899,47 @@
     typedef typename Parent::Value Value;
 
-    ///Constructor
-    MulMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
-    /// \e
-    Value operator[](Key k) const {return m1[k]*m2[k];}
-  };
-  
-  ///Returns a \c MulMap class
-
-  ///This function just returns a \c MulMap class.
-  ///\relates MulMap
-  template<typename M1, typename M2> 
+    /// Constructor
+    MulMap(const M1 &m1,const M2 &m2) : _m1(m1), _m2(m2) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m1[k]*_m2[k]; }
+  };
+
+  /// Returns a \ref MulMap class
+
+  /// This function just returns a \ref MulMap class.
+  ///
+  /// For example, if \c m1 and \c m2 are both maps with \c double
+  /// values, then <tt>mulMap(m1,m2)[x]</tt> will be equal to
+  /// <tt>m1[x]*m2[x]</tt>.
+  ///
+  /// \relates MulMap
+  template<typename M1, typename M2>
   inline MulMap<M1, M2> mulMap(const M1 &m1,const M2 &m2) {
     return MulMap<M1, M2>(m1,m2);
   }
- 
-  ///Scales a map with a constant.
-
-  ///This \ref concepts::ReadMap "read only map" returns the value of the
-  ///given map multiplied from the left side with a constant value.
-  ///Its \c Key and \c Value are inherited from \c M.
-  ///
-  ///Actually,
-  ///\code
-  ///  ScaleMap<X> sc(x,v);
-  ///\endcode
-  ///is equivalent to
-  ///\code
-  ///  ConstMap<X::Key, X::Value> c_tmp(v);
-  ///  MulMap<X, ConstMap<X::Key, X::Value> > sc(x,v);
-  ///\endcode
-  ///
-  ///\sa ScaleWriteMap
-  template<typename M, typename C = typename M::Value> 
-  class ScaleMap : public MapBase<typename M::Key, typename M::Value> {
-    const M& m;
-    C v;
-  public:
-    typedef MapBase<typename M::Key, typename M::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-
-    ///Constructor.
-    ///\param _m is the undelying map.
-    ///\param _v is the scaling value.
-    ScaleMap(const M &_m, const C &_v ) : m(_m), v(_v) {};
-    /// \e
-    Value operator[](Key k) const {return v * m[k];}
-  };
-
-  ///Scales a map with a constant (ReadWrite version).
-
-  ///This \ref concepts::ReadWriteMap "read-write map" returns the value of the
-  ///given map multiplied from the left side with a constant value. It can
-  ///also be used as write map if the \c / operator is defined between
-  ///\c Value and \c C and the given multiplier is not zero.
-  ///Its \c Key and \c Value are inherited from \c M.
-  ///
-  ///\sa ScaleMap
-  template<typename M, typename C = typename M::Value> 
-  class ScaleWriteMap : public MapBase<typename M::Key, typename M::Value> {
-    M& m;
-    C v;
-  public:
-    typedef MapBase<typename M::Key, typename M::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-
-    ///Constructor.
-    ///\param _m is the undelying map.
-    ///\param _v is the scaling value.
-    ScaleWriteMap(M &_m, const C &_v ) : m(_m), v(_v) {};
-    /// \e
-    Value operator[](Key k) const {return v * m[k];}
-    /// \e
-    void set(Key k, const Value& c) { m.set(k, c / v);}
-  };
-  
-  ///Returns a \c ScaleMap class
-
-  ///This function just returns a \c ScaleMap class.
-  ///\relates ScaleMap
-  template<typename M, typename C> 
-  inline ScaleMap<M, C> scaleMap(const M &m,const C &v) {
-    return ScaleMap<M, C>(m,v);
-  }
-
-  ///Returns a \c ScaleWriteMap class
-
-  ///This function just returns a \c ScaleWriteMap class.
-  ///\relates ScaleWriteMap
-  template<typename M, typename C> 
-  inline ScaleWriteMap<M, C> scaleMap(M &m,const C &v) {
-    return ScaleWriteMap<M, C>(m,v);
-  }
-
-  ///Quotient of two maps
-
-  ///This \ref concepts::ReadMap "read only map" returns the quotient of the
-  ///values of the two given maps.
-  ///Its \c Key and \c Value are inherited from \c M1.
-  ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
-  template<typename M1, typename M2> 
+
+
+  /// Quotient of two maps
+
+  /// This \ref concepts::ReadMap "read-only map" returns the quotient
+  /// of the values of the two given maps.
+  /// Its \c Key and \c Value types are inherited from \c M1.
+  /// The \c Key and \c Value of \c M2 must be convertible to those of
+  /// \c M1.
+  ///
+  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
+  /// \code
+  ///   DivMap<M1,M2> dm(m1,m2);
+  /// \endcode
+  /// <tt>dm[x]</tt> will be equal to <tt>m1[x]/m2[x]</tt>.
+  ///
+  /// The simplest way of using this map is through the divMap()
+  /// function.
+  ///
+  /// \sa AddMap, SubMap, MulMap
+  template<typename M1, typename M2>
   class DivMap : public MapBase<typename M1::Key, typename M1::Value> {
-    const M1& m1;
-    const M2& m2;
+    const M1 &_m1;
+    const M2 &_m2;
   public:
     typedef MapBase<typename M1::Key, typename M1::Value> Parent;
@@ -786,154 +947,250 @@
     typedef typename Parent::Value Value;
 
-    ///Constructor
-    DivMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
-    /// \e
-    Value operator[](Key k) const {return m1[k]/m2[k];}
-  };
-  
-  ///Returns a \c DivMap class
-
-  ///This function just returns a \c DivMap class.
-  ///\relates DivMap
-  template<typename M1, typename M2> 
+    /// Constructor
+    DivMap(const M1 &m1,const M2 &m2) : _m1(m1), _m2(m2) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m1[k]/_m2[k]; }
+  };
+
+  /// Returns a \ref DivMap class
+
+  /// This function just returns a \ref DivMap class.
+  ///
+  /// For example, if \c m1 and \c m2 are both maps with \c double
+  /// values, then <tt>divMap(m1,m2)[x]</tt> will be equal to
+  /// <tt>m1[x]/m2[x]</tt>.
+  ///
+  /// \relates DivMap
+  template<typename M1, typename M2>
   inline DivMap<M1, M2> divMap(const M1 &m1,const M2 &m2) {
     return DivMap<M1, M2>(m1,m2);
   }
-  
-  ///Composition of two maps
-
-  ///This \ref concepts::ReadMap "read only map" returns the composition of
-  ///two given maps.
-  ///That is to say, if \c m1 is of type \c M1 and \c m2 is of \c M2,
-  ///then for
-  ///\code
-  ///  ComposeMap<M1, M2> cm(m1,m2);
-  ///\endcode
-  /// <tt>cm[x]</tt> will be equal to <tt>m1[m2[x]]</tt>.
-  ///
-  ///Its \c Key is inherited from \c M2 and its \c Value is from \c M1.
-  ///\c M2::Value must be convertible to \c M1::Key.
-  ///
-  ///\sa CombineMap
-  ///
-  ///\todo Check the requirements.
-  template <typename M1, typename M2> 
-  class ComposeMap : public MapBase<typename M2::Key, typename M1::Value> {
-    const M1& m1;
-    const M2& m2;
-  public:
-    typedef MapBase<typename M2::Key, typename M1::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-    ComposeMap(const M1 &_m1,const M2 &_m2) : m1(_m1), m2(_m2) {};
-    
-    /// \e
-
-
-    /// \todo Use the  MapTraits once it is ported.
-    ///
-
-    //typename MapTraits<M1>::ConstReturnValue
-    typename M1::Value
-    operator[](Key k) const {return m1[m2[k]];}
-  };
-
-  ///Returns a \c ComposeMap class
-
-  ///This function just returns a \c ComposeMap class.
-  ///\relates ComposeMap
-  template <typename M1, typename M2> 
-  inline ComposeMap<M1, M2> composeMap(const M1 &m1,const M2 &m2) {
-    return ComposeMap<M1, M2>(m1,m2);
-  }
-  
-  ///Combine of two maps using an STL (binary) functor.
-
-  ///Combine of two maps using an STL (binary) functor.
-  ///
-  ///This \ref concepts::ReadMap "read only map" takes two maps and a
-  ///binary functor and returns the composition of the two
-  ///given maps unsing the functor. 
-  ///That is to say, if \c m1 and \c m2 is of type \c M1 and \c M2
-  ///and \c f is of \c F, then for
-  ///\code
-  ///  CombineMap<M1,M2,F,V> cm(m1,m2,f);
-  ///\endcode
-  /// <tt>cm[x]</tt> will be equal to <tt>f(m1[x],m2[x])</tt>
-  ///
-  ///Its \c Key is inherited from \c M1 and its \c Value is \c V.
-  ///\c M2::Value and \c M1::Value must be convertible to the corresponding
-  ///input parameter of \c F and the return type of \c F must be convertible
-  ///to \c V.
-  ///
-  ///\sa ComposeMap
-  ///
-  ///\todo Check the requirements.
-  template<typename M1, typename M2, typename F,
-	   typename V = typename F::result_type> 
-  class CombineMap : public MapBase<typename M1::Key, V> {
-    const M1& m1;
-    const M2& m2;
-    F f;
-  public:
-    typedef MapBase<typename M1::Key, V> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-    CombineMap(const M1 &_m1,const M2 &_m2,const F &_f = F())
-      : m1(_m1), m2(_m2), f(_f) {};
-    /// \e
-    Value operator[](Key k) const {return f(m1[k],m2[k]);}
-  };
-  
-  ///Returns a \c CombineMap class
-
-  ///This function just returns a \c CombineMap class.
-  ///
-  ///For example if \c m1 and \c m2 are both \c double valued maps, then 
-  ///\code
-  ///combineMap(m1,m2,std::plus<double>())
-  ///\endcode
-  ///is equivalent to
-  ///\code
-  ///addMap(m1,m2)
-  ///\endcode
-  ///
-  ///This function is specialized for adaptable binary function
-  ///classes and C++ functions.
-  ///
-  ///\relates CombineMap
-  template<typename M1, typename M2, typename F, typename V> 
-  inline CombineMap<M1, M2, F, V> 
-  combineMap(const M1& m1,const M2& m2, const F& f) {
-    return CombineMap<M1, M2, F, V>(m1,m2,f);
-  }
-
-  template<typename M1, typename M2, typename F> 
-  inline CombineMap<M1, M2, F, typename F::result_type> 
-  combineMap(const M1& m1, const M2& m2, const F& f) {
-    return combineMap<M1, M2, F, typename F::result_type>(m1,m2,f);
-  }
-
-  template<typename M1, typename M2, typename K1, typename K2, typename V> 
-  inline CombineMap<M1, M2, V (*)(K1, K2), V> 
-  combineMap(const M1 &m1, const M2 &m2, V (*f)(K1, K2)) {
-    return combineMap<M1, M2, V (*)(K1, K2), V>(m1,m2,f);
-  }
-
-  ///Negative value of a map
-
-  ///This \ref concepts::ReadMap "read only map" returns the negative
-  ///value of the value returned by the given map.
-  ///Its \c Key and \c Value are inherited from \c M.
-  ///The unary \c - operator must be defined for \c Value, of course.
-  ///
-  ///\sa NegWriteMap
-  template<typename M> 
+
+
+  /// Shifts a map with a constant.
+
+  /// This \ref concepts::ReadMap "read-only map" returns the sum of
+  /// the given map and a constant value (i.e. it shifts the map with
+  /// the constant). Its \c Key and \c Value are inherited from \c M.
+  ///
+  /// Actually,
+  /// \code
+  ///   ShiftMap<M> sh(m,v);
+  /// \endcode
+  /// is equivalent to
+  /// \code
+  ///   ConstMap<M::Key, M::Value> cm(v);
+  ///   AddMap<M, ConstMap<M::Key, M::Value> > sh(m,cm);
+  /// \endcode
+  ///
+  /// The simplest way of using this map is through the shiftMap()
+  /// function.
+  ///
+  /// \sa ShiftWriteMap
+  template<typename M, typename C = typename M::Value>
+  class ShiftMap : public MapBase<typename M::Key, typename M::Value> {
+    const M &_m;
+    C _v;
+  public:
+    typedef MapBase<typename M::Key, typename M::Value> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+
+    /// Constructor.
+    /// \param m The undelying map.
+    /// \param v The constant value.
+    ShiftMap(const M &m, const C &v) : _m(m), _v(v) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m[k]+_v; }
+  };
+
+  /// Shifts a map with a constant (read-write version).
+
+  /// This \ref concepts::ReadWriteMap "read-write map" returns the sum
+  /// of the given map and a constant value (i.e. it shifts the map with
+  /// the constant). Its \c Key and \c Value are inherited from \c M.
+  /// It makes also possible to write the map.
+  ///
+  /// The simplest way of using this map is through the shiftWriteMap()
+  /// function.
+  ///
+  /// \sa ShiftMap
+  template<typename M, typename C = typename M::Value>
+  class ShiftWriteMap : public MapBase<typename M::Key, typename M::Value> {
+    M &_m;
+    C _v;
+  public:
+    typedef MapBase<typename M::Key, typename M::Value> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+
+    /// Constructor.
+    /// \param m The undelying map.
+    /// \param v The constant value.
+    ShiftWriteMap(M &m, const C &v) : _m(m), _v(v) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m[k]+_v; }
+    /// \e
+    void set(const Key &k, const Value &v) { _m.set(k, v-_v); }
+  };
+
+  /// Returns a \ref ShiftMap class
+
+  /// This function just returns a \ref ShiftMap class.
+  ///
+  /// For example, if \c m is a map with \c double values and \c v is
+  /// \c double, then <tt>shiftMap(m,v)[x]</tt> will be equal to
+  /// <tt>m[x]+v</tt>.
+  ///
+  /// \relates ShiftMap
+  template<typename M, typename C>
+  inline ShiftMap<M, C> shiftMap(const M &m, const C &v) {
+    return ShiftMap<M, C>(m,v);
+  }
+
+  /// Returns a \ref ShiftWriteMap class
+
+  /// This function just returns a \ref ShiftWriteMap class.
+  ///
+  /// For example, if \c m is a map with \c double values and \c v is
+  /// \c double, then <tt>shiftWriteMap(m,v)[x]</tt> will be equal to
+  /// <tt>m[x]+v</tt>.
+  /// Moreover it makes also possible to write the map.
+  ///
+  /// \relates ShiftWriteMap
+  template<typename M, typename C>
+  inline ShiftWriteMap<M, C> shiftWriteMap(M &m, const C &v) {
+    return ShiftWriteMap<M, C>(m,v);
+  }
+
+
+  /// Scales a map with a constant.
+
+  /// This \ref concepts::ReadMap "read-only map" returns the value of
+  /// the given map multiplied from the left side with a constant value.
+  /// Its \c Key and \c Value are inherited from \c M.
+  ///
+  /// Actually,
+  /// \code
+  ///   ScaleMap<M> sc(m,v);
+  /// \endcode
+  /// is equivalent to
+  /// \code
+  ///   ConstMap<M::Key, M::Value> cm(v);
+  ///   MulMap<ConstMap<M::Key, M::Value>, M> sc(cm,m);
+  /// \endcode
+  ///
+  /// The simplest way of using this map is through the scaleMap()
+  /// function.
+  ///
+  /// \sa ScaleWriteMap
+  template<typename M, typename C = typename M::Value>
+  class ScaleMap : public MapBase<typename M::Key, typename M::Value> {
+    const M &_m;
+    C _v;
+  public:
+    typedef MapBase<typename M::Key, typename M::Value> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+
+    /// Constructor.
+    /// \param m The undelying map.
+    /// \param v The constant value.
+    ScaleMap(const M &m, const C &v) : _m(m), _v(v) {}
+    /// \e
+    Value operator[](const Key &k) const { return _v*_m[k]; }
+  };
+
+  /// Scales a map with a constant (read-write version).
+
+  /// This \ref concepts::ReadWriteMap "read-write map" returns the value of
+  /// the given map multiplied from the left side with a constant value.
+  /// Its \c Key and \c Value are inherited from \c M.
+  /// It can also be used as write map if the \c / operator is defined
+  /// between \c Value and \c C and the given multiplier is not zero.
+  ///
+  /// The simplest way of using this map is through the scaleWriteMap()
+  /// function.
+  ///
+  /// \sa ScaleMap
+  template<typename M, typename C = typename M::Value>
+  class ScaleWriteMap : public MapBase<typename M::Key, typename M::Value> {
+    M &_m;
+    C _v;
+  public:
+    typedef MapBase<typename M::Key, typename M::Value> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+
+    /// Constructor.
+    /// \param m The undelying map.
+    /// \param v The constant value.
+    ScaleWriteMap(M &m, const C &v) : _m(m), _v(v) {}
+    /// \e
+    Value operator[](const Key &k) const { return _v*_m[k]; }
+    /// \e
+    void set(const Key &k, const Value &v) { _m.set(k, v/_v); }
+  };
+
+  /// Returns a \ref ScaleMap class
+
+  /// This function just returns a \ref ScaleMap class.
+  ///
+  /// For example, if \c m is a map with \c double values and \c v is
+  /// \c double, then <tt>scaleMap(m,v)[x]</tt> will be equal to
+  /// <tt>v*m[x]</tt>.
+  ///
+  /// \relates ScaleMap
+  template<typename M, typename C>
+  inline ScaleMap<M, C> scaleMap(const M &m, const C &v) {
+    return ScaleMap<M, C>(m,v);
+  }
+
+  /// Returns a \ref ScaleWriteMap class
+
+  /// This function just returns a \ref ScaleWriteMap class.
+  ///
+  /// For example, if \c m is a map with \c double values and \c v is
+  /// \c double, then <tt>scaleWriteMap(m,v)[x]</tt> will be equal to
+  /// <tt>v*m[x]</tt>.
+  /// Moreover it makes also possible to write the map.
+  ///
+  /// \relates ScaleWriteMap
+  template<typename M, typename C>
+  inline ScaleWriteMap<M, C> scaleWriteMap(M &m, const C &v) {
+    return ScaleWriteMap<M, C>(m,v);
+  }
+
+
+  /// Negative of a map
+
+  /// This \ref concepts::ReadMap "read-only map" returns the negative
+  /// of the values of the given map (using the unary \c - operator).
+  /// Its \c Key and \c Value are inherited from \c M.
+  ///
+  /// If M::Value is \c int, \c double etc., then
+  /// \code
+  ///   NegMap<M> neg(m);
+  /// \endcode
+  /// is equivalent to
+  /// \code
+  ///   ScaleMap<M> neg(m,-1);
+  /// \endcode
+  ///
+  /// The simplest way of using this map is through the negMap()
+  /// function.
+  ///
+  /// \sa NegWriteMap
+  template<typename M>
   class NegMap : public MapBase<typename M::Key, typename M::Value> {
-    const M& m;
+    const M& _m;
   public:
     typedef MapBase<typename M::Key, typename M::Value> Parent;
@@ -941,21 +1198,34 @@
     typedef typename Parent::Value Value;
 
-    ///Constructor
-    NegMap(const M &_m) : m(_m) {};
-    /// \e
-    Value operator[](Key k) const {return -m[k];}
-  };
-  
-  ///Negative value of a map (ReadWrite version)
-
-  ///This \ref concepts::ReadWriteMap "read-write map" returns the negative
-  ///value of the value returned by the given map.
-  ///Its \c Key and \c Value are inherited from \c M.
-  ///The unary \c - operator must be defined for \c Value, of course.
+    /// Constructor
+    NegMap(const M &m) : _m(m) {}
+    /// \e
+    Value operator[](const Key &k) const { return -_m[k]; }
+  };
+
+  /// Negative of a map (read-write version)
+
+  /// This \ref concepts::ReadWriteMap "read-write map" returns the
+  /// negative of the values of the given map (using the unary \c -
+  /// operator).
+  /// Its \c Key and \c Value are inherited from \c M.
+  /// It makes also possible to write the map.
+  ///
+  /// If M::Value is \c int, \c double etc., then
+  /// \code
+  ///   NegWriteMap<M> neg(m);
+  /// \endcode
+  /// is equivalent to
+  /// \code
+  ///   ScaleWriteMap<M> neg(m,-1);
+  /// \endcode
+  ///
+  /// The simplest way of using this map is through the negWriteMap()
+  /// function.
   ///
   /// \sa NegMap
-  template<typename M> 
+  template<typename M>
   class NegWriteMap : public MapBase<typename M::Key, typename M::Value> {
-    M& m;
+    M &_m;
   public:
     typedef MapBase<typename M::Key, typename M::Value> Parent;
@@ -963,40 +1233,53 @@
     typedef typename Parent::Value Value;
 
-    ///Constructor
-    NegWriteMap(M &_m) : m(_m) {};
-    /// \e
-    Value operator[](Key k) const {return -m[k];}
-    /// \e
-    void set(Key k, const Value& v) { m.set(k, -v); }
-  };
-
-  ///Returns a \c NegMap class
-
-  ///This function just returns a \c NegMap class.
-  ///\relates NegMap
-  template <typename M> 
+    /// Constructor
+    NegWriteMap(M &m) : _m(m) {}
+    /// \e
+    Value operator[](const Key &k) const { return -_m[k]; }
+    /// \e
+    void set(const Key &k, const Value &v) { _m.set(k, -v); }
+  };
+
+  /// Returns a \ref NegMap class
+
+  /// This function just returns a \ref NegMap class.
+  ///
+  /// For example, if \c m is a map with \c double values, then
+  /// <tt>negMap(m)[x]</tt> will be equal to <tt>-m[x]</tt>.
+  ///
+  /// \relates NegMap
+  template <typename M>
   inline NegMap<M> negMap(const M &m) {
     return NegMap<M>(m);
   }
 
-  ///Returns a \c NegWriteMap class
-
-  ///This function just returns a \c NegWriteMap class.
-  ///\relates NegWriteMap
-  template <typename M> 
-  inline NegWriteMap<M> negMap(M &m) {
+  /// Returns a \ref NegWriteMap class
+
+  /// This function just returns a \ref NegWriteMap class.
+  ///
+  /// For example, if \c m is a map with \c double values, then
+  /// <tt>negWriteMap(m)[x]</tt> will be equal to <tt>-m[x]</tt>.
+  /// Moreover it makes also possible to write the map.
+  ///
+  /// \relates NegWriteMap
+  template <typename M>
+  inline NegWriteMap<M> negWriteMap(M &m) {
     return NegWriteMap<M>(m);
   }
 
-  ///Absolute value of a map
-
-  ///This \ref concepts::ReadMap "read only map" returns the absolute value
-  ///of the value returned by the given map.
-  ///Its \c Key and \c Value are inherited from \c M. 
-  ///\c Value must be comparable to \c 0 and the unary \c -
-  ///operator must be defined for it, of course.
-  template<typename M> 
+
+  /// Absolute value of a map
+
+  /// This \ref concepts::ReadMap "read-only map" returns the absolute
+  /// value of the values of the given map.
+  /// Its \c Key and \c Value are inherited from \c M.
+  /// \c Value must be comparable to \c 0 and the unary \c -
+  /// operator must be defined for it, of course.
+  ///
+  /// The simplest way of using this map is through the absMap()
+  /// function.
+  template<typename M>
   class AbsMap : public MapBase<typename M::Key, typename M::Value> {
-    const M& m;
+    const M &_m;
   public:
     typedef MapBase<typename M::Key, typename M::Value> Parent;
@@ -1004,206 +1287,223 @@
     typedef typename Parent::Value Value;
 
-    ///Constructor
-    AbsMap(const M &_m) : m(_m) {};
-    /// \e
-    Value operator[](Key k) const {
-      Value tmp = m[k]; 
+    /// Constructor
+    AbsMap(const M &m) : _m(m) {}
+    /// \e
+    Value operator[](const Key &k) const {
+      Value tmp = _m[k];
       return tmp >= 0 ? tmp : -tmp;
     }
 
   };
-  
-  ///Returns an \c AbsMap class
-
-  ///This function just returns an \c AbsMap class.
-  ///\relates AbsMap
-  template<typename M> 
+
+  /// Returns an \ref AbsMap class
+
+  /// This function just returns an \ref AbsMap class.
+  ///
+  /// For example, if \c m is a map with \c double values, then
+  /// <tt>absMap(m)[x]</tt> will be equal to <tt>m[x]</tt> if
+  /// it is positive or zero and <tt>-m[x]</tt> if <tt>m[x]</tt> is
+  /// negative.
+  ///
+  /// \relates AbsMap
+  template<typename M>
   inline AbsMap<M> absMap(const M &m) {
     return AbsMap<M>(m);
   }
 
-  ///Converts an STL style functor to a map
-
-  ///This \ref concepts::ReadMap "read only map" returns the value
-  ///of a given functor.
-  ///
-  ///Template parameters \c K and \c V will become its
-  ///\c Key and \c Value. 
-  ///In most cases they have to be given explicitly because a 
-  ///functor typically does not provide \c argument_type and 
-  ///\c result_type typedefs.
-  ///
-  ///Parameter \c F is the type of the used functor.
-  ///
-  ///\sa MapFunctor
-  template<typename F, 
-	   typename K = typename F::argument_type, 
-	   typename V = typename F::result_type> 
-  class FunctorMap : public MapBase<K, V> {
-    F f;
-  public:
-    typedef MapBase<K, V> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-    FunctorMap(const F &_f = F()) : f(_f) {}
-    /// \e
-    Value operator[](Key k) const { return f(k);}
-  };
+  /// @}
   
-  ///Returns a \c FunctorMap class
-
-  ///This function just returns a \c FunctorMap class.
-  ///
-  ///This function is specialized for adaptable binary function
-  ///classes and C++ functions.
-  ///
-  ///\relates FunctorMap
-  template<typename K, typename V, typename F> inline 
-  FunctorMap<F, K, V> functorMap(const F &f) {
-    return FunctorMap<F, K, V>(f);
-  }
-
-  template <typename F> inline 
-  FunctorMap<F, typename F::argument_type, typename F::result_type> 
-  functorMap(const F &f) {
-    return FunctorMap<F, typename F::argument_type, 
-      typename F::result_type>(f);
-  }
-
-  template <typename K, typename V> inline 
-  FunctorMap<V (*)(K), K, V> functorMap(V (*f)(K)) {
-    return FunctorMap<V (*)(K), K, V>(f);
-  }
-
-
-  ///Converts a map to an STL style (unary) functor
-
-  ///This class Converts a map to an STL style (unary) functor.
-  ///That is it provides an <tt>operator()</tt> to read its values.
-  ///
-  ///For the sake of convenience it also works as
-  ///a ususal \ref concepts::ReadMap "readable map",
-  ///i.e. <tt>operator[]</tt> and the \c Key and \c Value typedefs also exist.
-  ///
-  ///\sa FunctorMap
-  template <typename M> 
-  class MapFunctor : public MapBase<typename M::Key, typename M::Value> {
-    const M& m;
-  public:
-    typedef MapBase<typename M::Key, typename M::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    typedef typename M::Key argument_type;
-    typedef typename M::Value result_type;
-
-    ///Constructor
-    MapFunctor(const M &_m) : m(_m) {};
-    ///\e
-    Value operator()(Key k) const {return m[k];}
-    ///\e
-    Value operator[](Key k) const {return m[k];}
-  };
-  
-  ///Returns a \c MapFunctor class
-
-  ///This function just returns a \c MapFunctor class.
-  ///\relates MapFunctor
-  template<typename M> 
-  inline MapFunctor<M> mapFunctor(const M &m) {
-    return MapFunctor<M>(m);
-  }
-
-  ///Just readable version of \ref ForkWriteMap
-
-  ///This map has two \ref concepts::ReadMap "readable map"
-  ///parameters and each read request will be passed just to the
-  ///first map. This class is the just readable map type of \c ForkWriteMap.
-  ///
-  ///The \c Key and \c Value are inherited from \c M1.
-  ///The \c Key and \c Value of \c M2 must be convertible from those of \c M1.
-  ///
-  ///\sa ForkWriteMap
-  ///
-  /// \todo Why is it needed?
-  template<typename  M1, typename M2> 
-  class ForkMap : public MapBase<typename M1::Key, typename M1::Value> {
-    const M1& m1;
-    const M2& m2;
-  public:
-    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-    ForkMap(const M1 &_m1, const M2 &_m2) : m1(_m1), m2(_m2) {};
-    /// \e
-    Value operator[](Key k) const {return m1[k];}
-  };
-
-
-  ///Applies all map setting operations to two maps
-
-  ///This map has two \ref concepts::WriteMap "writable map"
-  ///parameters and each write request will be passed to both of them.
-  ///If \c M1 is also \ref concepts::ReadMap "readable",
-  ///then the read operations will return the
-  ///corresponding values of \c M1.
-  ///
-  ///The \c Key and \c Value are inherited from \c M1.
-  ///The \c Key and \c Value of \c M2 must be convertible from those of \c M1.
-  ///
-  ///\sa ForkMap
-  template<typename  M1, typename M2> 
-  class ForkWriteMap : public MapBase<typename M1::Key, typename M1::Value> {
-    M1& m1;
-    M2& m2;
-  public:
-    typedef MapBase<typename M1::Key, typename M1::Value> Parent;
-    typedef typename Parent::Key Key;
-    typedef typename Parent::Value Value;
-
-    ///Constructor
-    ForkWriteMap(M1 &_m1, M2 &_m2) : m1(_m1), m2(_m2) {};
-    ///\e
-    Value operator[](Key k) const {return m1[k];}
-    ///\e
-    void set(Key k, const Value &v) {m1.set(k,v); m2.set(k,v);}
-  };
-  
-  ///Returns a \c ForkMap class
-
-  ///This function just returns a \c ForkMap class.
-  ///\relates ForkMap
-  template <typename M1, typename M2> 
-  inline ForkMap<M1, M2> forkMap(const M1 &m1, const M2 &m2) {
-    return ForkMap<M1, M2>(m1,m2);
-  }
-
-  ///Returns a \c ForkWriteMap class
-
-  ///This function just returns a \c ForkWriteMap class.
-  ///\relates ForkWriteMap
-  template <typename M1, typename M2> 
-  inline ForkWriteMap<M1, M2> forkMap(M1 &m1, M2 &m2) {
-    return ForkWriteMap<M1, M2>(m1,m2);
-  }
-
-
-  
-  /* ************* BOOL MAPS ******************* */
-  
-  ///Logical 'not' of a map
-  
-  ///This bool \ref concepts::ReadMap "read only map" returns the 
-  ///logical negation of the value returned by the given map.
-  ///Its \c Key is inherited from \c M, its \c Value is \c bool.
-  ///
-  ///\sa NotWriteMap
-  template <typename M> 
+  // Logical maps and map adaptors:
+
+  /// \addtogroup maps
+  /// @{
+
+  /// Constant \c true map.
+
+  /// This \ref concepts::ReadMap "read-only map" assigns \c true to
+  /// each key.
+  ///
+  /// Note that
+  /// \code
+  ///   TrueMap<K> tm;
+  /// \endcode
+  /// is equivalent to
+  /// \code
+  ///   ConstMap<K,bool> tm(true);
+  /// \endcode
+  ///
+  /// \sa FalseMap
+  /// \sa ConstMap
+  template <typename K>
+  class TrueMap : public MapBase<K, bool> {
+  public:
+    typedef MapBase<K, bool> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Gives back \c true.
+    Value operator[](const Key&) const { return true; }
+  };
+
+  /// Returns a \ref TrueMap class
+
+  /// This function just returns a \ref TrueMap class.
+  /// \relates TrueMap
+  template<typename K>
+  inline TrueMap<K> trueMap() {
+    return TrueMap<K>();
+  }
+
+
+  /// Constant \c false map.
+
+  /// This \ref concepts::ReadMap "read-only map" assigns \c false to
+  /// each key.
+  ///
+  /// Note that
+  /// \code
+  ///   FalseMap<K> fm;
+  /// \endcode
+  /// is equivalent to
+  /// \code
+  ///   ConstMap<K,bool> fm(false);
+  /// \endcode
+  ///
+  /// \sa TrueMap
+  /// \sa ConstMap
+  template <typename K>
+  class FalseMap : public MapBase<K, bool> {
+  public:
+    typedef MapBase<K, bool> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Gives back \c false.
+    Value operator[](const Key&) const { return false; }
+  };
+
+  /// Returns a \ref FalseMap class
+
+  /// This function just returns a \ref FalseMap class.
+  /// \relates FalseMap
+  template<typename K>
+  inline FalseMap<K> falseMap() {
+    return FalseMap<K>();
+  }
+
+  /// @}
+
+  /// \addtogroup map_adaptors
+  /// @{
+
+  /// Logical 'and' of two maps
+
+  /// This \ref concepts::ReadMap "read-only map" returns the logical
+  /// 'and' of the values of the two given maps.
+  /// Its \c Key type is inherited from \c M1 and its \c Value type is
+  /// \c bool. \c M2::Key must be convertible to \c M1::Key.
+  ///
+  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
+  /// \code
+  ///   AndMap<M1,M2> am(m1,m2);
+  /// \endcode
+  /// <tt>am[x]</tt> will be equal to <tt>m1[x]&&m2[x]</tt>.
+  ///
+  /// The simplest way of using this map is through the andMap()
+  /// function.
+  ///
+  /// \sa OrMap
+  /// \sa NotMap, NotWriteMap
+  template<typename M1, typename M2>
+  class AndMap : public MapBase<typename M1::Key, bool> {
+    const M1 &_m1;
+    const M2 &_m2;
+  public:
+    typedef MapBase<typename M1::Key, bool> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+    AndMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m1[k]&&_m2[k]; }
+  };
+
+  /// Returns an \ref AndMap class
+
+  /// This function just returns an \ref AndMap class.
+  ///
+  /// For example, if \c m1 and \c m2 are both maps with \c bool values,
+  /// then <tt>andMap(m1,m2)[x]</tt> will be equal to
+  /// <tt>m1[x]&&m2[x]</tt>.
+  ///
+  /// \relates AndMap
+  template<typename M1, typename M2>
+  inline AndMap<M1, M2> andMap(const M1 &m1, const M2 &m2) {
+    return AndMap<M1, M2>(m1,m2);
+  }
+
+
+  /// Logical 'or' of two maps
+
+  /// This \ref concepts::ReadMap "read-only map" returns the logical
+  /// 'or' of the values of the two given maps.
+  /// Its \c Key type is inherited from \c M1 and its \c Value type is
+  /// \c bool. \c M2::Key must be convertible to \c M1::Key.
+  ///
+  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
+  /// \code
+  ///   OrMap<M1,M2> om(m1,m2);
+  /// \endcode
+  /// <tt>om[x]</tt> will be equal to <tt>m1[x]||m2[x]</tt>.
+  ///
+  /// The simplest way of using this map is through the orMap()
+  /// function.
+  ///
+  /// \sa AndMap
+  /// \sa NotMap, NotWriteMap
+  template<typename M1, typename M2>
+  class OrMap : public MapBase<typename M1::Key, bool> {
+    const M1 &_m1;
+    const M2 &_m2;
+  public:
+    typedef MapBase<typename M1::Key, bool> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+    OrMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m1[k]||_m2[k]; }
+  };
+
+  /// Returns an \ref OrMap class
+
+  /// This function just returns an \ref OrMap class.
+  ///
+  /// For example, if \c m1 and \c m2 are both maps with \c bool values,
+  /// then <tt>orMap(m1,m2)[x]</tt> will be equal to
+  /// <tt>m1[x]||m2[x]</tt>.
+  ///
+  /// \relates OrMap
+  template<typename M1, typename M2>
+  inline OrMap<M1, M2> orMap(const M1 &m1, const M2 &m2) {
+    return OrMap<M1, M2>(m1,m2);
+  }
+
+
+  /// Logical 'not' of a map
+
+  /// This \ref concepts::ReadMap "read-only map" returns the logical
+  /// negation of the values of the given map.
+  /// Its \c Key is inherited from \c M and its \c Value is \c bool.
+  ///
+  /// The simplest way of using this map is through the notMap()
+  /// function.
+  ///
+  /// \sa NotWriteMap
+  template <typename M>
   class NotMap : public MapBase<typename M::Key, bool> {
-    const M& m;
+    const M &_m;
   public:
     typedef MapBase<typename M::Key, bool> Parent;
@@ -1212,20 +1512,24 @@
 
     /// Constructor
-    NotMap(const M &_m) : m(_m) {};
-    ///\e
-    Value operator[](Key k) const {return !m[k];}
-  };
-
-  ///Logical 'not' of a map (ReadWrie version)
-  
-  ///This bool \ref concepts::ReadWriteMap "read-write map" returns the 
-  ///logical negation of the value returned by the given map. When it is set,
-  ///the opposite value is set to the original map.
-  ///Its \c Key is inherited from \c M, its \c Value is \c bool.
-  ///
-  ///\sa NotMap
-  template <typename M> 
+    NotMap(const M &m) : _m(m) {}
+    /// \e
+    Value operator[](const Key &k) const { return !_m[k]; }
+  };
+
+  /// Logical 'not' of a map (read-write version)
+
+  /// This \ref concepts::ReadWriteMap "read-write map" returns the
+  /// logical negation of the values of the given map.
+  /// Its \c Key is inherited from \c M and its \c Value is \c bool.
+  /// It makes also possible to write the map. When a value is set,
+  /// the opposite value is set to the original map.
+  ///
+  /// The simplest way of using this map is through the notWriteMap()
+  /// function.
+  ///
+  /// \sa NotMap
+  template <typename M>
   class NotWriteMap : public MapBase<typename M::Key, bool> {
-    M& m;
+    M &_m;
   public:
     typedef MapBase<typename M::Key, bool> Parent;
@@ -1234,403 +1538,133 @@
 
     /// Constructor
-    NotWriteMap(M &_m) : m(_m) {};
-    ///\e
-    Value operator[](Key k) const {return !m[k];}
-    ///\e
-    void set(Key k, bool v) { m.set(k, !v); }
-  };
-  
-  ///Returns a \c NotMap class
-  
-  ///This function just returns a \c NotMap class.
-  ///\relates NotMap
-  template <typename M> 
+    NotWriteMap(M &m) : _m(m) {}
+    /// \e
+    Value operator[](const Key &k) const { return !_m[k]; }
+    /// \e
+    void set(const Key &k, bool v) { _m.set(k, !v); }
+  };
+
+  /// Returns a \ref NotMap class
+
+  /// This function just returns a \ref NotMap class.
+  ///
+  /// For example, if \c m is a map with \c bool values, then
+  /// <tt>notMap(m)[x]</tt> will be equal to <tt>!m[x]</tt>.
+  ///
+  /// \relates NotMap
+  template <typename M>
   inline NotMap<M> notMap(const M &m) {
     return NotMap<M>(m);
   }
-  
-  ///Returns a \c NotWriteMap class
-  
-  ///This function just returns a \c NotWriteMap class.
-  ///\relates NotWriteMap
-  template <typename M> 
-  inline NotWriteMap<M> notMap(M &m) {
+
+  /// Returns a \ref NotWriteMap class
+
+  /// This function just returns a \ref NotWriteMap class.
+  ///
+  /// For example, if \c m is a map with \c bool values, then
+  /// <tt>notWriteMap(m)[x]</tt> will be equal to <tt>!m[x]</tt>.
+  /// Moreover it makes also possible to write the map.
+  ///
+  /// \relates NotWriteMap
+  template <typename M>
+  inline NotWriteMap<M> notWriteMap(M &m) {
     return NotWriteMap<M>(m);
   }
 
-  namespace _maps_bits {
-
-    template <typename Value>
-    struct Identity {
-      typedef Value argument_type;
-      typedef Value result_type;
-      Value operator()(const Value& val) const {
-	return val;
-      }
-    };
-
-    template <typename _Iterator, typename Enable = void>
-    struct IteratorTraits {
-      typedef typename std::iterator_traits<_Iterator>::value_type Value;
-    };
-
-    template <typename _Iterator>
-    struct IteratorTraits<_Iterator,
-      typename exists<typename _Iterator::container_type>::type> 
-    {
-      typedef typename _Iterator::container_type::value_type Value;
-    };
-
-  }
-  
-
-  /// \brief Writable bool map for logging each \c true assigned element
-  ///
-  /// A \ref concepts::ReadWriteMap "read-write" bool map for logging 
-  /// each \c true assigned element, i.e it copies all the keys set 
-  /// to \c true to the given iterator.
-  ///
-  /// \note The container of the iterator should contain space 
-  /// for each element.
-  ///
-  /// The following example shows how you can write the edges found by 
-  /// the \ref Prim algorithm directly to the standard output.
-  ///\code
-  /// typedef IdMap<Graph, Edge> EdgeIdMap;
-  /// EdgeIdMap edgeId(graph);
-  ///
-  /// typedef MapFunctor<EdgeIdMap> EdgeIdFunctor;
-  /// EdgeIdFunctor edgeIdFunctor(edgeId);
-  ///
-  /// StoreBoolMap<ostream_iterator<int>, EdgeIdFunctor> 
-  ///   writerMap(ostream_iterator<int>(cout, " "), edgeIdFunctor);
-  ///
-  /// prim(graph, cost, writerMap);
-  ///\endcode
-  ///
-  ///\sa BackInserterBoolMap 
-  ///\sa FrontInserterBoolMap 
-  ///\sa InserterBoolMap 
-  ///
-  ///\todo Revise the name of this class and the related ones.
-  template <typename _Iterator, 
-            typename _Functor =
-            _maps_bits::Identity<typename _maps_bits::
-                                 IteratorTraits<_Iterator>::Value> >
-  class StoreBoolMap {
-  public:
-    typedef _Iterator Iterator;
-
-    typedef typename _Functor::argument_type Key;
-    typedef bool Value;
-
-    typedef _Functor Functor;
-
-    /// Constructor
-    StoreBoolMap(Iterator it, const Functor& functor = Functor()) 
-      : _begin(it), _end(it), _functor(functor) {}
-
-    /// Gives back the given iterator set for the first key
-    Iterator begin() const {
-      return _begin;
-    }
- 
-    /// Gives back the the 'after the last' iterator
-    Iterator end() const {
-      return _end;
-    }
-
-    /// The \c set function of the map
-    void set(const Key& key, Value value) const {
-      if (value) {
-	*_end++ = _functor(key);
-      }
-    }
-    
-  private:
-    Iterator _begin;
-    mutable Iterator _end;
-    Functor _functor;
-  };
-
-  /// \brief Writable bool map for logging each \c true assigned element in 
-  /// a back insertable container.
-  ///
-  /// Writable bool map for logging each \c true assigned element by pushing
-  /// them into a back insertable container.
-  /// It can be used to retrieve the items into a standard
-  /// container. The next example shows how you can store the
-  /// edges found by the Prim algorithm in a vector.
-  ///
-  ///\code
-  /// vector<Edge> span_tree_edges;
-  /// BackInserterBoolMap<vector<Edge> > inserter_map(span_tree_edges);
-  /// prim(graph, cost, inserter_map);
-  ///\endcode
-  ///
-  ///\sa StoreBoolMap
-  ///\sa FrontInserterBoolMap
-  ///\sa InserterBoolMap
-  template <typename Container,
-            typename Functor =
-            _maps_bits::Identity<typename Container::value_type> >
-  class BackInserterBoolMap {
-  public:
-    typedef typename Functor::argument_type Key;
-    typedef bool Value;
-
-    /// Constructor
-    BackInserterBoolMap(Container& _container, 
-                        const Functor& _functor = Functor()) 
-      : container(_container), functor(_functor) {}
-
-    /// The \c set function of the map
-    void set(const Key& key, Value value) {
-      if (value) {
-	container.push_back(functor(key));
-      }
-    }
-    
-  private:
-    Container& container;
-    Functor functor;
-  };
-
-  /// \brief Writable bool map for logging each \c true assigned element in 
-  /// a front insertable container.
-  ///
-  /// Writable bool map for logging each \c true assigned element by pushing
-  /// them into a front insertable container.
-  /// It can be used to retrieve the items into a standard
-  /// container. For example see \ref BackInserterBoolMap.
-  ///
-  ///\sa BackInserterBoolMap
-  ///\sa InserterBoolMap
-  template <typename Container,
-            typename Functor =
-            _maps_bits::Identity<typename Container::value_type> >
-  class FrontInserterBoolMap {
-  public:
-    typedef typename Functor::argument_type Key;
-    typedef bool Value;
-
-    /// Constructor
-    FrontInserterBoolMap(Container& _container,
-                         const Functor& _functor = Functor()) 
-      : container(_container), functor(_functor) {}
-
-    /// The \c set function of the map
-    void set(const Key& key, Value value) {
-      if (value) {
-	container.push_front(functor(key));
-      }
-    }
-    
-  private:
-    Container& container;    
-    Functor functor;
-  };
-
-  /// \brief Writable bool map for storing each \c true assigned element in 
-  /// an insertable container.
-  ///
-  /// Writable bool map for storing each \c true assigned element in an 
-  /// insertable container. It will insert all the keys set to \c true into
-  /// the container.
-  ///
-  /// For example, if you want to store the cut arcs of the strongly
-  /// connected components in a set you can use the next code:
-  ///
-  ///\code
-  /// set<Arc> cut_arcs;
-  /// InserterBoolMap<set<Arc> > inserter_map(cut_arcs);
-  /// stronglyConnectedCutArcs(digraph, cost, inserter_map);
-  ///\endcode
-  ///
-  ///\sa BackInserterBoolMap
-  ///\sa FrontInserterBoolMap
-  template <typename Container,
-            typename Functor =
-            _maps_bits::Identity<typename Container::value_type> >
-  class InserterBoolMap {
-  public:
-    typedef typename Container::value_type Key;
-    typedef bool Value;
-
-    /// Constructor with specified iterator
-    
-    /// Constructor with specified iterator.
-    /// \param _container The container for storing the elements.
-    /// \param _it The elements will be inserted before this iterator.
-    /// \param _functor The functor that is used when an element is stored.
-    InserterBoolMap(Container& _container, typename Container::iterator _it,
-                    const Functor& _functor = Functor()) 
-      : container(_container), it(_it), functor(_functor) {}
-
-    /// Constructor
-
-    /// Constructor without specified iterator.
-    /// The elements will be inserted before <tt>_container.end()</tt>.
-    /// \param _container The container for storing the elements.
-    /// \param _functor The functor that is used when an element is stored.
-    InserterBoolMap(Container& _container, const Functor& _functor = Functor())
-      : container(_container), it(_container.end()), functor(_functor) {}
-
-    /// The \c set function of the map
-    void set(const Key& key, Value value) {
-      if (value) {
-	it = container.insert(it, functor(key));
-        ++it;
-      }
-    }
-    
-  private:
-    Container& container;
-    typename Container::iterator it;
-    Functor functor;
-  };
-
-  /// \brief Writable bool map for filling each \c true assigned element with a 
-  /// given value.
-  ///
-  /// Writable bool map for filling each \c true assigned element with a 
-  /// given value. The value can set the container.
-  ///
-  /// The following code finds the connected components of a graph
-  /// and stores it in the \c comp map:
-  ///\code
-  /// typedef Graph::NodeMap<int> ComponentMap;
-  /// ComponentMap comp(graph);
-  /// typedef FillBoolMap<Graph::NodeMap<int> > ComponentFillerMap;
-  /// ComponentFillerMap filler(comp, 0);
-  ///
-  /// Dfs<Graph>::DefProcessedMap<ComponentFillerMap>::Create dfs(graph);
-  /// dfs.processedMap(filler);
-  /// dfs.init();
-  /// for (NodeIt it(graph); it != INVALID; ++it) {
-  ///   if (!dfs.reached(it)) {
-  ///     dfs.addSource(it);
-  ///     dfs.start();
-  ///     ++filler.fillValue();
-  ///   }
-  /// }
-  ///\endcode
-  template <typename Map>
-  class FillBoolMap {
-  public:
-    typedef typename Map::Key Key;
-    typedef bool Value;
-
-    /// Constructor
-    FillBoolMap(Map& _map, const typename Map::Value& _fill) 
-      : map(_map), fill(_fill) {}
-
-    /// Constructor
-    FillBoolMap(Map& _map) 
-      : map(_map), fill() {}
-
-    /// Gives back the current fill value
-    const typename Map::Value& fillValue() const {
-      return fill;
-    } 
-
-    /// Gives back the current fill value
-    typename Map::Value& fillValue() {
-      return fill;
-    } 
-
-    /// Sets the current fill value
-    void fillValue(const typename Map::Value& _fill) {
-      fill = _fill;
-    } 
-
-    /// The \c set function of the map
-    void set(const Key& key, Value value) {
-      if (value) {
-	map.set(key, fill);
-      }
-    }
-    
-  private:
-    Map& map;
-    typename Map::Value fill;
-  };
-
-
-  /// \brief Writable bool map for storing the sequence number of 
-  /// \c true assignments.  
-  /// 
-  /// Writable bool map that stores for each \c true assigned elements  
-  /// the sequence number of this setting.
-  /// It makes it easy to calculate the leaving
-  /// order of the nodes in the \c Dfs algorithm.
-  ///
-  ///\code
-  /// typedef Digraph::NodeMap<int> OrderMap;
-  /// OrderMap order(digraph);
-  /// typedef SettingOrderBoolMap<OrderMap> OrderSetterMap;
-  /// OrderSetterMap setter(order);
-  /// Dfs<Digraph>::DefProcessedMap<OrderSetterMap>::Create dfs(digraph);
-  /// dfs.processedMap(setter);
-  /// dfs.init();
-  /// for (NodeIt it(digraph); it != INVALID; ++it) {
-  ///   if (!dfs.reached(it)) {
-  ///     dfs.addSource(it);
-  ///     dfs.start();
-  ///   }
-  /// }
-  ///\endcode
-  ///
-  /// The storing of the discovering order is more difficult because the
-  /// ReachedMap should be readable in the dfs algorithm but the setting
-  /// order map is not readable. Thus we must use the fork map:
-  ///
-  ///\code
-  /// typedef Digraph::NodeMap<int> OrderMap;
-  /// OrderMap order(digraph);
-  /// typedef SettingOrderBoolMap<OrderMap> OrderSetterMap;
-  /// OrderSetterMap setter(order);
-  /// typedef Digraph::NodeMap<bool> StoreMap;
-  /// StoreMap store(digraph);
-  ///
-  /// typedef ForkWriteMap<StoreMap, OrderSetterMap> ReachedMap;
-  /// ReachedMap reached(store, setter);
-  ///
-  /// Dfs<Digraph>::DefReachedMap<ReachedMap>::Create dfs(digraph);
-  /// dfs.reachedMap(reached);
-  /// dfs.init();
-  /// for (NodeIt it(digraph); it != INVALID; ++it) {
-  ///   if (!dfs.reached(it)) {
-  ///     dfs.addSource(it);
-  ///     dfs.start();
-  ///   }
-  /// }
-  ///\endcode
-  template <typename Map>
-  class SettingOrderBoolMap {
-  public:
-    typedef typename Map::Key Key;
-    typedef bool Value;
-
-    /// Constructor
-    SettingOrderBoolMap(Map& _map) 
-      : map(_map), counter(0) {}
-
-    /// Number of set operations.
-    int num() const {
-      return counter;
-    }
-
-    /// The \c set function of the map
-    void set(const Key& key, Value value) {
-      if (value) {
-	map.set(key, counter++);
-      }
-    }
-    
-  private:
-    Map& map;
-    int counter;
-  };
+
+  /// Combination of two maps using the \c == operator
+
+  /// This \ref concepts::ReadMap "read-only map" assigns \c true to
+  /// the keys for which the corresponding values of the two maps are
+  /// equal.
+  /// Its \c Key type is inherited from \c M1 and its \c Value type is
+  /// \c bool. \c M2::Key must be convertible to \c M1::Key.
+  ///
+  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
+  /// \code
+  ///   EqualMap<M1,M2> em(m1,m2);
+  /// \endcode
+  /// <tt>em[x]</tt> will be equal to <tt>m1[x]==m2[x]</tt>.
+  ///
+  /// The simplest way of using this map is through the equalMap()
+  /// function.
+  ///
+  /// \sa LessMap
+  template<typename M1, typename M2>
+  class EqualMap : public MapBase<typename M1::Key, bool> {
+    const M1 &_m1;
+    const M2 &_m2;
+  public:
+    typedef MapBase<typename M1::Key, bool> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+    EqualMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m1[k]==_m2[k]; }
+  };
+
+  /// Returns an \ref EqualMap class
+
+  /// This function just returns an \ref EqualMap class.
+  ///
+  /// For example, if \c m1 and \c m2 are maps with keys and values of
+  /// the same type, then <tt>equalMap(m1,m2)[x]</tt> will be equal to
+  /// <tt>m1[x]==m2[x]</tt>.
+  ///
+  /// \relates EqualMap
+  template<typename M1, typename M2>
+  inline EqualMap<M1, M2> equalMap(const M1 &m1, const M2 &m2) {
+    return EqualMap<M1, M2>(m1,m2);
+  }
+
+
+  /// Combination of two maps using the \c < operator
+
+  /// This \ref concepts::ReadMap "read-only map" assigns \c true to
+  /// the keys for which the corresponding value of the first map is
+  /// less then the value of the second map.
+  /// Its \c Key type is inherited from \c M1 and its \c Value type is
+  /// \c bool. \c M2::Key must be convertible to \c M1::Key.
+  ///
+  /// If \c m1 is of type \c M1 and \c m2 is of \c M2, then for
+  /// \code
+  ///   LessMap<M1,M2> lm(m1,m2);
+  /// \endcode
+  /// <tt>lm[x]</tt> will be equal to <tt>m1[x]<m2[x]</tt>.
+  ///
+  /// The simplest way of using this map is through the lessMap()
+  /// function.
+  ///
+  /// \sa EqualMap
+  template<typename M1, typename M2>
+  class LessMap : public MapBase<typename M1::Key, bool> {
+    const M1 &_m1;
+    const M2 &_m2;
+  public:
+    typedef MapBase<typename M1::Key, bool> Parent;
+    typedef typename Parent::Key Key;
+    typedef typename Parent::Value Value;
+
+    /// Constructor
+    LessMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {}
+    /// \e
+    Value operator[](const Key &k) const { return _m1[k]<_m2[k]; }
+  };
+
+  /// Returns an \ref LessMap class
+
+  /// This function just returns an \ref LessMap class.
+  ///
+  /// For example, if \c m1 and \c m2 are maps with keys and values of
+  /// the same type, then <tt>lessMap(m1,m2)[x]</tt> will be equal to
+  /// <tt>m1[x]<m2[x]</tt>.
+  ///
+  /// \relates LessMap
+  template<typename M1, typename M2>
+  inline LessMap<M1, M2> lessMap(const M1 &m1, const M2 &m2) {
+    return LessMap<M1, M2>(m1,m2);
+  }
 
   /// @}
Index: test/maps_test.cc
===================================================================
--- test/maps_test.cc	(revision 39)
+++ test/maps_test.cc	(revision 82)
@@ -38,20 +38,24 @@
   typedef B result_type;
 
-  B operator()(const A &) const {return B();}
+  B operator()(const A&) const { return B(); }
+private:
+  F& operator=(const F&);
 };
 
-int func(A) {return 3;}
-
-int binc(int, B) {return 4;}
-
-typedef ReadMap<A,double> DoubleMap;
-typedef ReadWriteMap<A, double> WriteDoubleMap;
-
-typedef ReadMap<A,bool> BoolMap;
+int func(A) { return 3; }
+
+int binc(int a, B) { return a+1; }
+
+typedef ReadMap<A, double> DoubleMap;
+typedef ReadWriteMap<A, double> DoubleWriteMap;
+typedef ReferenceMap<A, double, double&, const double&> DoubleRefMap;
+
+typedef ReadMap<A, bool> BoolMap;
 typedef ReadWriteMap<A, bool> BoolWriteMap;
+typedef ReferenceMap<A, bool, bool&, const bool&> BoolRefMap;
 
 int main()
-{ // checking graph components
-  
+{
+  // Map concepts
   checkConcept<ReadMap<A,B>, ReadMap<A,B> >();
   checkConcept<WriteMap<A,B>, WriteMap<A,B> >();
@@ -59,50 +63,230 @@
   checkConcept<ReferenceMap<A,B,B&,const B&>, ReferenceMap<A,B,B&,const B&> >();
 
-  checkConcept<ReadMap<A,double>, AddMap<DoubleMap,DoubleMap> >();
-  checkConcept<ReadMap<A,double>, SubMap<DoubleMap,DoubleMap> >();
-  checkConcept<ReadMap<A,double>, MulMap<DoubleMap,DoubleMap> >();
-  checkConcept<ReadMap<A,double>, DivMap<DoubleMap,DoubleMap> >();
-  checkConcept<ReadMap<A,double>, NegMap<DoubleMap> >();
-  checkConcept<ReadWriteMap<A,double>, NegWriteMap<WriteDoubleMap> >();
-  checkConcept<ReadMap<A,double>, AbsMap<DoubleMap> >();
-  checkConcept<ReadMap<A,double>, ShiftMap<DoubleMap> >();
-  checkConcept<ReadWriteMap<A,double>, ShiftWriteMap<WriteDoubleMap> >();
-  checkConcept<ReadMap<A,double>, ScaleMap<DoubleMap> >();
-  checkConcept<ReadWriteMap<A,double>, ScaleWriteMap<WriteDoubleMap> >();
-  checkConcept<ReadMap<A,double>, ForkMap<DoubleMap, DoubleMap> >();
-  checkConcept<ReadWriteMap<A,double>, 
-    ForkWriteMap<WriteDoubleMap, WriteDoubleMap> >();
-  
-  checkConcept<ReadMap<B,double>, ComposeMap<DoubleMap,ReadMap<B,A> > >();
-
-  checkConcept<ReadMap<A,B>, FunctorMap<F, A, B> >();
-
-  checkConcept<ReadMap<A, bool>, NotMap<BoolMap> >();
-  checkConcept<ReadWriteMap<A, bool>, NotWriteMap<BoolWriteMap> >();
-
-  checkConcept<WriteMap<A, bool>, StoreBoolMap<A*> >();
-  checkConcept<WriteMap<A, bool>, BackInserterBoolMap<std::deque<A> > >();
-  checkConcept<WriteMap<A, bool>, FrontInserterBoolMap<std::deque<A> > >();
-  checkConcept<WriteMap<A, bool>, InserterBoolMap<std::set<A> > >();
-  checkConcept<WriteMap<A, bool>, FillBoolMap<WriteMap<A, B> > >();
-  checkConcept<WriteMap<A, bool>, SettingOrderBoolMap<WriteMap<A, int> > >();
-
-  int a;
-  
-  a=mapFunctor(constMap<A,int>(2))(A());
-  check(a==2,"Something is wrong with mapFunctor");
-
-  B b;
-  b=functorMap(F())[A()];
-
-  a=functorMap(&func)[A()];
-  check(a==3,"Something is wrong with functorMap");
-
-  a=combineMap(constMap<B, int, 1>(), identityMap<B>(), &binc)[B()];
-  check(a==4,"Something is wrong with combineMap");
-  
-
-  std::cout << __FILE__ ": All tests passed.\n";
-  
+  // NullMap
+  {
+    checkConcept<ReadWriteMap<A,B>, NullMap<A,B> >();
+    NullMap<A,B> map1;
+    NullMap<A,B> map2 = map1;
+    map1 = nullMap<A,B>();
+  }
+
+  // ConstMap
+  {
+    checkConcept<ReadWriteMap<A,B>, ConstMap<A,B> >();
+    ConstMap<A,B> map1;
+    ConstMap<A,B> map2(B());
+    ConstMap<A,B> map3 = map1;
+    map1 = constMap<A>(B());
+    map1.setAll(B());
+
+    checkConcept<ReadWriteMap<A,int>, ConstMap<A,int> >();
+    check(constMap<A>(10)[A()] == 10, "Something is wrong with ConstMap");
+
+    checkConcept<ReadWriteMap<A,int>, ConstMap<A,Const<int,10> > >();
+    ConstMap<A,Const<int,10> > map4;
+    ConstMap<A,Const<int,10> > map5 = map4;
+    map4 = map5;
+    check(map4[A()] == 10 && map5[A()] == 10, "Something is wrong with ConstMap");
+  }
+
+  // IdentityMap
+  {
+    checkConcept<ReadMap<A,A>, IdentityMap<A> >();
+    IdentityMap<A> map1;
+    IdentityMap<A> map2 = map1;
+    map1 = identityMap<A>();
+
+    checkConcept<ReadMap<double,double>, IdentityMap<double> >();
+    check(identityMap<double>()[1.0] == 1.0 && identityMap<double>()[3.14] == 3.14,
+          "Something is wrong with IdentityMap");
+  }
+
+  // RangeMap
+  {
+    checkConcept<ReferenceMap<int,B,B&,const B&>, RangeMap<B> >();
+    RangeMap<B> map1;
+    RangeMap<B> map2(10);
+    RangeMap<B> map3(10,B());
+    RangeMap<B> map4 = map1;
+    RangeMap<B> map5 = rangeMap<B>();
+    RangeMap<B> map6 = rangeMap<B>(10);
+    RangeMap<B> map7 = rangeMap(10,B());
+
+    checkConcept< ReferenceMap<int, double, double&, const double&>,
+                  RangeMap<double> >();
+    std::vector<double> v(10, 0);
+    v[5] = 100;
+    RangeMap<double> map8(v);
+    RangeMap<double> map9 = rangeMap(v);
+    check(map9.size() == 10 && map9[2] == 0 && map9[5] == 100,
+          "Something is wrong with RangeMap");
+  }
+
+  // SparseMap
+  {
+    checkConcept<ReferenceMap<A,B,B&,const B&>, SparseMap<A,B> >();
+    SparseMap<A,B> map1;
+    SparseMap<A,B> map2(B());
+    SparseMap<A,B> map3 = sparseMap<A,B>();
+    SparseMap<A,B> map4 = sparseMap<A>(B());
+
+    checkConcept< ReferenceMap<double, int, int&, const int&>,
+                  SparseMap<double, int> >();
+    std::map<double, int> m;
+    SparseMap<double, int> map5(m);
+    SparseMap<double, int> map6(m,10);
+    SparseMap<double, int> map7 = sparseMap(m);
+    SparseMap<double, int> map8 = sparseMap(m,10);
+
+    check(map5[1.0] == 0 && map5[3.14] == 0 && map6[1.0] == 10 && map6[3.14] == 10,
+          "Something is wrong with SparseMap");
+    map5[1.0] = map6[3.14] = 100;
+    check(map5[1.0] == 100 && map5[3.14] == 0 && map6[1.0] == 10 && map6[3.14] == 100,
+          "Something is wrong with SparseMap");
+  }
+
+  // ComposeMap
+  {
+    typedef ComposeMap<DoubleMap, ReadMap<B,A> > CompMap;
+    checkConcept<ReadMap<B,double>, CompMap>();
+    CompMap map1(DoubleMap(),ReadMap<B,A>());
+    CompMap map2 = composeMap(DoubleMap(), ReadMap<B,A>());
+
+    SparseMap<double, bool> m1(false); m1[3.14] = true;
+    RangeMap<double> m2(2); m2[0] = 3.0; m2[1] = 3.14;
+    check(!composeMap(m1,m2)[0] && composeMap(m1,m2)[1], "Something is wrong with ComposeMap")
+  }
+
+  // CombineMap
+  {
+    typedef CombineMap<DoubleMap, DoubleMap, std::plus<double> > CombMap;
+    checkConcept<ReadMap<A,double>, CombMap>();
+    CombMap map1(DoubleMap(), DoubleMap());
+    CombMap map2 = combineMap(DoubleMap(), DoubleMap(), std::plus<double>());
+
+    check(combineMap(constMap<B,int,2>(), identityMap<B>(), &binc)[B()] == 3,
+          "Something is wrong with CombineMap");
+  }
+
+  // FunctorToMap, MapToFunctor
+  {
+    checkConcept<ReadMap<A,B>, FunctorToMap<F,A,B> >();
+    checkConcept<ReadMap<A,B>, FunctorToMap<F> >();
+    FunctorToMap<F> map1;
+    FunctorToMap<F> map2(F());
+    B b = functorToMap(F())[A()];
+
+    checkConcept<ReadMap<A,B>, MapToFunctor<ReadMap<A,B> > >();
+    MapToFunctor<ReadMap<A,B> > map(ReadMap<A,B>());
+
+    check(functorToMap(&func)[A()] == 3, "Something is wrong with FunctorToMap");
+    check(mapToFunctor(constMap<A,int>(2))(A()) == 2, "Something is wrong with MapToFunctor");
+    check(mapToFunctor(functorToMap(&func))(A()) == 3 && mapToFunctor(functorToMap(&func))[A()] == 3,
+          "Something is wrong with FunctorToMap or MapToFunctor");
+    check(functorToMap(mapToFunctor(constMap<A,int>(2)))[A()] == 2,
+          "Something is wrong with FunctorToMap or MapToFunctor");
+  }
+
+  // ConvertMap
+  {
+    checkConcept<ReadMap<double,double>, ConvertMap<ReadMap<double, int>, double> >();
+    ConvertMap<RangeMap<bool>, int> map1(rangeMap(1, true));
+    ConvertMap<RangeMap<bool>, int> map2 = convertMap<int>(rangeMap(2, false));
+  }
+
+  // ForkMap
+  {
+    checkConcept<DoubleWriteMap, ForkMap<DoubleWriteMap, DoubleWriteMap> >();
+
+    typedef RangeMap<double> RM;
+    typedef SparseMap<int, double> SM;
+    RM m1(10, -1);
+    SM m2(-1);
+    checkConcept<ReadWriteMap<int, double>, ForkMap<RM, SM> >();
+    checkConcept<ReadWriteMap<int, double>, ForkMap<SM, RM> >();
+    ForkMap<RM, SM> map1(m1,m2);
+    ForkMap<SM, RM> map2 = forkMap(m2,m1);
+    map2.set(5, 10);
+    check(m1[1] == -1 && m1[5] == 10 && m2[1] == -1 && m2[5] == 10 && map2[1] == -1 && map2[5] == 10,
+          "Something is wrong with ForkMap");
+  }
+
+  // Arithmetic maps:
+  // - AddMap, SubMap, MulMap, DivMap
+  // - ShiftMap, ShiftWriteMap, ScaleMap, ScaleWriteMap
+  // - NegMap, NegWriteMap, AbsMap
+  {
+    checkConcept<DoubleMap, AddMap<DoubleMap,DoubleMap> >();
+    checkConcept<DoubleMap, SubMap<DoubleMap,DoubleMap> >();
+    checkConcept<DoubleMap, MulMap<DoubleMap,DoubleMap> >();
+    checkConcept<DoubleMap, DivMap<DoubleMap,DoubleMap> >();
+
+    ConstMap<int, double> c1(1.0), c2(3.14);
+    IdentityMap<int> im;
+    ConvertMap<IdentityMap<int>, double> id(im);
+    check(addMap(c1,id)[0] == 1.0  && addMap(c1,id)[10] == 11.0, "Something is wrong with AddMap");
+    check(subMap(id,c1)[0] == -1.0 && subMap(id,c1)[10] == 9.0,  "Something is wrong with SubMap");
+    check(mulMap(id,c2)[0] == 0    && mulMap(id,c2)[2]  == 6.28, "Something is wrong with MulMap");
+    check(divMap(c2,id)[1] == 3.14 && divMap(c2,id)[2]  == 1.57, "Something is wrong with DivMap");
+
+    checkConcept<DoubleMap, ShiftMap<DoubleMap> >();
+    checkConcept<DoubleWriteMap, ShiftWriteMap<DoubleWriteMap> >();
+    checkConcept<DoubleMap, ScaleMap<DoubleMap> >();
+    checkConcept<DoubleWriteMap, ScaleWriteMap<DoubleWriteMap> >();
+    checkConcept<DoubleMap, NegMap<DoubleMap> >();
+    checkConcept<DoubleWriteMap, NegWriteMap<DoubleWriteMap> >();
+    checkConcept<DoubleMap, AbsMap<DoubleMap> >();
+
+    check(shiftMap(id, 2.0)[1] == 3.0 && shiftMap(id, 2.0)[10] == 12.0,
+          "Something is wrong with ShiftMap");
+    check(shiftWriteMap(id, 2.0)[1] == 3.0 && shiftWriteMap(id, 2.0)[10] == 12.0,
+          "Something is wrong with ShiftWriteMap");
+    check(scaleMap(id, 2.0)[1] == 2.0 && scaleMap(id, 2.0)[10] == 20.0,
+          "Something is wrong with ScaleMap");
+    check(scaleWriteMap(id, 2.0)[1] == 2.0 && scaleWriteMap(id, 2.0)[10] == 20.0,
+          "Something is wrong with ScaleWriteMap");
+    check(negMap(id)[1] == -1.0 && negMap(id)[-10] == 10.0,
+          "Something is wrong with NegMap");
+    check(negWriteMap(id)[1] == -1.0 && negWriteMap(id)[-10] == 10.0,
+          "Something is wrong with NegWriteMap");
+    check(absMap(id)[1] == 1.0 && absMap(id)[-10] == 10.0,
+          "Something is wrong with AbsMap");
+  }
+
+  // Logical maps:
+  // - TrueMap, FalseMap
+  // - AndMap, OrMap
+  // - NotMap, NotWriteMap
+  // - EqualMap, LessMap
+  {
+    checkConcept<BoolMap, TrueMap<A> >();
+    checkConcept<BoolMap, FalseMap<A> >();
+    checkConcept<BoolMap, AndMap<BoolMap,BoolMap> >();
+    checkConcept<BoolMap, OrMap<BoolMap,BoolMap> >();
+    checkConcept<BoolMap, NotMap<BoolMap> >();
+    checkConcept<BoolWriteMap, NotWriteMap<BoolWriteMap> >();
+    checkConcept<BoolMap, EqualMap<DoubleMap,DoubleMap> >();
+    checkConcept<BoolMap, LessMap<DoubleMap,DoubleMap> >();
+
+    TrueMap<int> tm;
+    FalseMap<int> fm;
+    RangeMap<bool> rm(2);
+    rm[0] = true; rm[1] = false;
+    check(andMap(tm,rm)[0] && !andMap(tm,rm)[1] && !andMap(fm,rm)[0] && !andMap(fm,rm)[1],
+          "Something is wrong with AndMap");
+    check(orMap(tm,rm)[0] && orMap(tm,rm)[1] && orMap(fm,rm)[0] && !orMap(fm,rm)[1],
+          "Something is wrong with OrMap");
+    check(!notMap(rm)[0] && notMap(rm)[1], "Something is wrong with NotMap");
+    check(!notWriteMap(rm)[0] && notWriteMap(rm)[1], "Something is wrong with NotWriteMap");
+
+    ConstMap<int, double> cm(2.0);
+    IdentityMap<int> im;
+    ConvertMap<IdentityMap<int>, double> id(im);
+    check(lessMap(id,cm)[1] && !lessMap(id,cm)[2] && !lessMap(id,cm)[3],
+          "Something is wrong with LessMap");
+    check(!equalMap(id,cm)[1] && equalMap(id,cm)[2] && !equalMap(id,cm)[3],
+          "Something is wrong with EqualMap");
+  }
+
   return 0;
 }
