COIN-OR::LEMON - Graph Library

Ticket #147: f5965bbf1353.patch

File f5965bbf1353.patch, 2.6 KB (added by Peter Kovacs, 12 years ago)
  • doc/named-param.dox

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1222013387 -7200
    # Node ID f5965bbf13538cce384305a3c0a5e6da091de807
    # Parent  986d30f5c1c0c39a7eb2953a2b216e245410beaa
    Improvements in named-param.dox (ticket #147)
    
    diff --git a/doc/named-param.dox b/doc/named-param.dox
    a b  
    1 /* -*- C++ -*-
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
    22 *
    3  * This file is a part of LEMON, a generic C++ optimization library
     3 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    55 * Copyright (C) 2003-2008
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     
    2525Several modern languages provide a convenient way to refer the
    2626function parameters by name also when you call the function. It is
    2727especially comfortable in case of a function having tons of parameters
    28 with natural default values. Sadly, C++ lack this amenity. 
     28with natural default values. Sadly, C++ lack this amenity.
    2929
    3030However, with a crafty trick and with some little
    3131inconvenience, it is possible to emulate is.
    3232The example below shows how to do it.
    3333
    3434\code
    35 class namedFn 
     35class namedFn
    3636{
    3737  int _id;
    3838  double _val;
    3939  int _dim;
    40  
     40
    4141  public:
    4242  namedFn() : _id(0), _val(1), _dim(2) {}
    4343  namedFn& id(int p)     { _id  = p ; return *this; }
     
    4545  namedFn& dim(int p)    { _dim = p ; return *this; }
    4646
    4747  run() {
    48   std::cout << "Here comes the function itself\n" <<
    49             << "With parameters "
    50             << _id << ", " << _val << ", " << _dim << std::endl;
     48    std::cout << "Here comes the function itself\n" <<
     49              << "With parameters "
     50              << _id << ", " << _val << ", " << _dim << std::endl;
    5151  }
    5252};
    5353\endcode
     
    7676
    7777\section named-templ-func-param Named Function Template Parameters
    7878
    79 A named parameter can also be a template functions. The usage is
     79A named parameter can also be a template function. The usage is
    8080exactly the same, but the implementation behind is a kind of black
    8181magic and they are the dirtiest part of the LEMON code.
    8282
     
    103103be used as shown in the following example.
    104104
    105105\code
    106 Dijkstra<>::SetPredNodeMap<NullMap<Node,Node> >::Create
     106Dijkstra<>::SetPredMap<NullMap<Node,Arc> >::Create
    107107\endcode
    108108
    109109It can also be used in conjunction with other named template
    110110parameters in arbitrary order.
    111111
    112112\code
    113 Dijkstra<>::SetDistMap<MyMap>::SetPredMap<NullMap<Node,Edge> >::Create
     113Dijkstra<>::SetDistMap<MyMap>::SetPredMap<NullMap<Node,Arc> >::Create
    114114\endcode
    115115
    116116The result will be an instantiated Dijkstra class, in which the