Doc tweaks

[SVN r1872]
This commit is contained in:
Dave Abrahams
2004-01-14 13:11:46 +00:00
parent 5d6a9c0581
commit 7c51ce7ae5

View File

@@ -30,10 +30,10 @@ __ ../../../index.htm
Introduction Introduction
============ ============
In C++ function parameters are given meaning by their position in In C++ function arguments are given meaning by their position in
the argument list. This protocol is fine when there are few the parameter list. This protocol is fine when there are few
parameters with default values, but as the number of parameters parameters with default values, but as the number of parameters
grows, so does the inconvenience of specifying parameters in the grows, so does the inconvenience of passing arguments in the
correct order, especially in the presence of default values: correct order, especially in the presence of default values:
* It can become difficult for readers to understand the meaning of * It can become difficult for readers to understand the meaning of
@@ -41,8 +41,8 @@ correct order, especially in the presence of default values:
window* w = new_window("alert", true, true, false, 77, 65); window* w = new_window("alert", true, true, false, 77, 65);
* Since meaning is given by position, we have to choose some, * Since meaning is given by position, we have to choose some
often arbitrary order, for parameters with default values, (often arbitrary) order for parameters with default values,
making some combinations of defaults unusable:: making some combinations of defaults unusable::
window* new_window( window* new_window(
@@ -60,9 +60,9 @@ correct order, especially in the presence of default values:
char const* name, bool border, ... char const* name, bool border, ...
, int width = 100, int heigh = width); // error! , int width = 100, int heigh = width); // error!
* Template types can not be deduced from the default values, * Template types can not be deduced from the default values, so
meaning we have to resort to overloading to provide default we have to resort to overloading to provide default values for
values for parameters with template type:: parameters with template type::
template<class T> void f(T x = 0); template<class T> void f(T x = 0);
@@ -109,19 +109,23 @@ First we define the named parameter keywords. This is done by creating
struct value_t; struct value_t;
namespace { namespace {
keyword<name_t> name; // keyword objects boost::keyword<name_t> name; // keyword objects
keyword<value_t> value; boost::keyword<value_t> value;
} }
Placing these keyword objects in an unnamed namespace will prevent Placing these keyword objects in an unnamed namespace will prevent
link errors when you declare keywords in header files. We also link errors when you declare keywords in header files [**Note**:
need to create a keywords list for our function:: the tag types should generally *not* be declared in an unnamed
namespace]. We also need to create a keywords list for our
function. These keywords should be declared in the same order as
their corresponding parameters appear in the function's parameter
list::
struct foo_keywords struct foo_keywords
: keywords< : boost::keywords<
name_t name_t
, value_t , value_t
> >
{}; {};
Defining the forwarding functions Defining the forwarding functions