File: conventions.qbk

package info (click to toggle)
boost1.74 1.74.0-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 464,084 kB
  • sloc: cpp: 3,338,324; xml: 131,293; python: 33,088; ansic: 14,336; asm: 4,034; sh: 3,351; makefile: 1,193; perl: 1,036; yacc: 478; php: 212; ruby: 102; lisp: 24; sql: 13; csh: 6
file content (69 lines) | stat: -rw-r--r-- 2,767 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
[/
 / Copyright (c) 2008 Eric Niebler
 /
 / Distributed under the Boost Software License, Version 1.0. (See accompanying
 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 /]

[/================================]
[section:naming Naming Conventions]
[/================================]

Proto is a large library and probably quite unlike any library you've used
before. Proto uses some consistent naming conventions to make it easier to
navigate, and they're described below.

[/================]
[heading Functions]
[/================]

All of Proto's functions are defined in the `boost::proto` namespace. For
example, there is a function called `value()` defined in `boost::proto` that
accepts a terminal expression and returns the terminal's value.

[/====================]
[heading Metafunctions]
[/====================]

Proto defines /metafunctions/ that correspond to each of Proto's free functions.
The metafunctions are used to compute the functions' return types. All of
Proto's metafunctions live in the `boost::proto::result_of` namespace and
have the same name as the functions to which they correspond. For instance,
there is a class template `boost::proto::result_of::value<>` that you can
use to compute the return type of the `boost::proto::value()` function.

[/=======================]
[heading Function Objects]
[/=======================]

Proto defines /function object/ equivalents of all of its free functions. (A
function object is an instance of a class type that defines an `operator()`
member function.) All of Proto's function object types are defined in the
`boost::proto::functional` namespace and have the same name as their
corresponding free functions. For example, `boost::proto::functional::value`
is a class that defines a function object that does the same thing as the
`boost::proto::value()` free function.

[/===========================]
[heading Primitive Transforms]
[/===========================]

Proto also defines /primitive transforms/ -- class types that can be used
to compose larger transforms for manipulating expression trees. Many of
Proto's free functions have corresponding primitive transforms. These live
in the `boost::proto` namespace and their names have a leading underscore.
For instance, the transform corresponding to the `value()` function is
called `boost::proto::_value`.

The following table summarizes the discussion above:

[table Proto Naming Conventions
  [[Entity]           [Example]                            ]
  [[Free Function]    [`boost::proto::value()`]            ]
  [[Metafunction]     [`boost::proto::result_of::value<>`] ]
  [[Function Object]  [`boost::proto::functional::value`]  ]
  [[Transform]        [`boost::proto::_value`]             ]
]

[endsect]