# HG changeset patch # User Peter Kovacs # Date 1222013387 -7200 # Node ID f5965bbf13538cce384305a3c0a5e6da091de807 # Parent 986d30f5c1c0c39a7eb2953a2b216e245410beaa Improvements in named-param.dox (ticket #147) diff -r 986d30f5c1c0 -r f5965bbf1353 doc/named-param.dox --- a/doc/named-param.dox Sun Sep 21 07:49:57 2008 +0100 +++ b/doc/named-param.dox Sun Sep 21 18:09:47 2008 +0200 @@ -1,6 +1,6 @@ -/* -*- C++ -*- +/* -*- mode: C++; indent-tabs-mode: nil; -*- * - * This file is a part of LEMON, a generic C++ optimization library + * This file is a part of LEMON, a generic C++ optimization library. * * Copyright (C) 2003-2008 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport @@ -25,19 +25,19 @@ Several modern languages provide a convenient way to refer the function parameters by name also when you call the function. It is especially comfortable in case of a function having tons of parameters -with natural default values. Sadly, C++ lack this amenity. +with natural default values. Sadly, C++ lack this amenity. However, with a crafty trick and with some little inconvenience, it is possible to emulate is. The example below shows how to do it. \code -class namedFn +class namedFn { int _id; double _val; int _dim; - + public: namedFn() : _id(0), _val(1), _dim(2) {} namedFn& id(int p) { _id = p ; return *this; } @@ -45,9 +45,9 @@ namedFn& dim(int p) { _dim = p ; return *this; } run() { - std::cout << "Here comes the function itself\n" << - << "With parameters " - << _id << ", " << _val << ", " << _dim << std::endl; + std::cout << "Here comes the function itself\n" << + << "With parameters " + << _id << ", " << _val << ", " << _dim << std::endl; } }; \endcode @@ -76,7 +76,7 @@ \section named-templ-func-param Named Function Template Parameters -A named parameter can also be a template functions. The usage is +A named parameter can also be a template function. The usage is exactly the same, but the implementation behind is a kind of black magic and they are the dirtiest part of the LEMON code. @@ -103,14 +103,14 @@ be used as shown in the following example. \code -Dijkstra<>::SetPredNodeMap >::Create +Dijkstra<>::SetPredMap >::Create \endcode It can also be used in conjunction with other named template parameters in arbitrary order. \code -Dijkstra<>::SetDistMap::SetPredMap >::Create +Dijkstra<>::SetDistMap::SetPredMap >::Create \endcode The result will be an instantiated Dijkstra class, in which the