conventions.qbk 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. [/
  2. / Copyright (c) 2008 Eric Niebler
  3. /
  4. / Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. /]
  7. [/================================]
  8. [section:naming Naming Conventions]
  9. [/================================]
  10. Proto is a large library and probably quite unlike any library you've used
  11. before. Proto uses some consistent naming conventions to make it easier to
  12. navigate, and they're described below.
  13. [/================]
  14. [heading Functions]
  15. [/================]
  16. All of Proto's functions are defined in the `boost::proto` namespace. For
  17. example, there is a function called `value()` defined in `boost::proto` that
  18. accepts a terminal expression and returns the terminal's value.
  19. [/====================]
  20. [heading Metafunctions]
  21. [/====================]
  22. Proto defines /metafunctions/ that correspond to each of Proto's free functions.
  23. The metafunctions are used to compute the functions' return types. All of
  24. Proto's metafunctions live in the `boost::proto::result_of` namespace and
  25. have the same name as the functions to which they correspond. For instance,
  26. there is a class template `boost::proto::result_of::value<>` that you can
  27. use to compute the return type of the `boost::proto::value()` function.
  28. [/=======================]
  29. [heading Function Objects]
  30. [/=======================]
  31. Proto defines /function object/ equivalents of all of its free functions. (A
  32. function object is an instance of a class type that defines an `operator()`
  33. member function.) All of Proto's function object types are defined in the
  34. `boost::proto::functional` namespace and have the same name as their
  35. corresponding free functions. For example, `boost::proto::functional::value`
  36. is a class that defines a function object that does the same thing as the
  37. `boost::proto::value()` free function.
  38. [/===========================]
  39. [heading Primitive Transforms]
  40. [/===========================]
  41. Proto also defines /primitive transforms/ -- class types that can be used
  42. to compose larger transforms for manipulating expression trees. Many of
  43. Proto's free functions have corresponding primitive transforms. These live
  44. in the `boost::proto` namespace and their names have a leading underscore.
  45. For instance, the transform corresponding to the `value()` function is
  46. called `boost::proto::_value`.
  47. The following table summarizes the discussion above:
  48. [table Proto Naming Conventions
  49. [[Entity] [Example] ]
  50. [[Free Function] [`boost::proto::value()`] ]
  51. [[Metafunction] [`boost::proto::result_of::value<>`] ]
  52. [[Function Object] [`boost::proto::functional::value`] ]
  53. [[Transform] [`boost::proto::_value`] ]
  54. ]
  55. [endsect]