compliance.qbk 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. [/ Copyright 2011 Daniel James.
  2. / Distributed under the Boost Software License, Version 1.0. (See accompanying
  3. / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ]
  4. [section:compliance Standard Compliance]
  5. The intent of Boost.Unordered is to implement a close (but imperfect)
  6. implementation of the C++17 standard, that will work with C++98 upwards.
  7. The wide compatibility does mean some comprimises have to be made.
  8. With a compiler and library that fully support C++11, the differences should
  9. be minor.
  10. [section:move Move emulation]
  11. Support for move semantics is implemented using Boost.Move. If rvalue
  12. references are available it will use them, but if not it uses a close,
  13. but imperfect emulation. On such compilers:
  14. * Non-copyable objects can be stored in the containers.
  15. They can be constructed in place using `emplace`, or if they support
  16. Boost.Move, moved into place.
  17. * The containers themselves are not movable.
  18. * Argument forwarding is not perfect.
  19. [endsect]
  20. [section:allocator_compliance Use of allocators]
  21. C++11 introduced a new allocator system. It's backwards compatible due to
  22. the lax requirements for allocators in the old standard, but might need
  23. some changes for allocators which worked with the old versions of the
  24. unordered containers.
  25. It uses a traits class, `allocator_traits` to handle the allocator
  26. adding extra functionality, and making some methods and types optional.
  27. During development a stable release of
  28. `allocator_traits` wasn't available so an internal partial implementation
  29. is always used in this version. Hopefully a future version will use the
  30. standard implementation where available.
  31. The member functions `construct`, `destroy` and `max_size` are now
  32. optional, if they're not available a fallback is used.
  33. A full implementation of `allocator_traits` requires sophisticated
  34. member function detection so that the fallback is used whenever the
  35. member function call is not well formed.
  36. This requires support for SFINAE expressions, which are available on
  37. GCC from version 4.4 and Clang.
  38. On other compilers, there's just a test to see if the allocator has
  39. a member, but no check that it can be called. So rather than using a
  40. fallback there will just be a compile error.
  41. `propagate_on_container_copy_assignment`,
  42. `propagate_on_container_move_assignment`,
  43. `propagate_on_container_swap` and
  44. `select_on_container_copy_construction` are also supported.
  45. Due to imperfect move emulation, some assignments might check
  46. `propagate_on_container_copy_assignment` on some compilers and
  47. `propagate_on_container_move_assignment` on others.
  48. [endsect]
  49. [section:construction Construction/Destruction using allocators]
  50. The following support is required for full use of C++11 style
  51. construction/destruction:
  52. * Variadic templates.
  53. * Piecewise construction of `std::pair`.
  54. * Either `std::allocator_traits` or expression SFINAE.
  55. This is detected using Boost.Config. The macro
  56. `BOOST_UNORDERED_CXX11_CONSTRUCTION` will be set to 1 if it is found, or 0
  57. otherwise.
  58. When this is the case `allocator_traits::construct` and
  59. `allocator_traits::destroy` will always be used, apart from when piecewise
  60. constructing a `std::pair` using `boost::tuple` (see [link
  61. unordered.compliance.pairs below]), but that should be easily avoided.
  62. When support is not available `allocator_traits::construct` and
  63. `allocator_traits::destroy` are never called.
  64. [endsect]
  65. [section:pointer_traits Pointer Traits]
  66. `pointer_traits` aren't used. Instead, pointer types are obtained from
  67. rebound allocators, this can cause problems if the allocator can't be
  68. used with incomplete types. If `const_pointer` is not defined in the
  69. allocator, `boost::pointer_to_other<pointer, const value_type>::type`
  70. is used to obtain a const pointer.
  71. [endsect]
  72. [#unordered.compliance.pairs]
  73. [section:pairs Pairs]
  74. Since the containers use `std::pair` they're limited to the version
  75. from the current standard library. But since C++11 `std::pair`'s
  76. `piecewise_construct` based constructor is very useful, `emplace`
  77. emulates it with a `piecewise_construct` in the `boost::unordered`
  78. namespace. So for example, the following will work:
  79. boost::unordered_multimap<std::string, std::complex> x;
  80. x.emplace(
  81. boost::unordered::piecewise_construct,
  82. boost::make_tuple("key"), boost::make_tuple(1, 2));
  83. Older drafts of the standard also supported variadic constructors
  84. for `std::pair`, where the first argument would be used for the
  85. first part of the pair, and the remaining for the second part.
  86. [endsect]
  87. [section:misc Miscellaneous]
  88. When swapping, `Pred` and `Hash` are not currently swapped by calling
  89. `swap`, their copy constructors are used. As a consequence when swapping
  90. an exception may be thrown from their copy constructor.
  91. Variadic constructor arguments for `emplace` are only used when both
  92. rvalue references and variadic template parameters are available.
  93. Otherwise `emplace` can only take up to 10 constructors arguments.
  94. [endsect]
  95. [endsect]