Update documentation

This commit is contained in:
Peter Dimov
2022-09-18 20:58:00 +03:00
parent ed235989ef
commit 123875dc83
15 changed files with 868 additions and 550 deletions
+21 -12
View File
@@ -3,12 +3,20 @@
// 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)
// Force use of assert.
#if defined(NDEBUG)
#undef NDEBUG
#endif
#include "./books.hpp"
#include <boost/container_hash/hash.hpp>
#include <boost/config.hpp>
#include <cassert>
// If std::unordered_set was available:
//#include <unordered_set>
// If std::unordered_set is available:
#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_SET)
#include <unordered_set>
#endif
// This example illustrates how to use boost::hash with a custom hash function.
// For full details, see the tutorial.
@@ -22,18 +30,19 @@ int main()
std::size_t knife_hash_value = book_hasher(knife);
(void)knife_hash_value; // suppress unused variable warning
// If std::unordered_set was available:
//
//std::unordered_set<library::book, boost::hash<library::book> > books;
//books.insert(knife);
//books.insert(library::book(2443, "Lindgren, Torgny", "Hash"));
//books.insert(library::book(1953, "Snyder, Bernadette M.",
// "Heavenly Hash: A Tasty Mix of a Mother's Meditations"));
// If std::unordered_set is available:
#if !defined(BOOST_NO_CXX11_HDR_UNORDERED_SET)
//assert(books.find(knife) != books.end());
//assert(books.find(dandelion) == books.end());
std::unordered_set<library::book, boost::hash<library::book> > books;
books.insert(knife);
books.insert(library::book(2443, "Lindgren, Torgny", "Hash"));
books.insert(library::book(1953, "Snyder, Bernadette M.",
"Heavenly Hash: A Tasty Mix of a Mother's Meditations"));
return 0;
assert(books.find(knife) != books.end());
assert(books.find(dandelion) == books.end());
#endif
}
namespace library