diff --git a/doc/hash.adoc b/doc/hash.adoc index 7362e61..9fda14b 100644 --- a/doc/hash.adoc +++ b/doc/hash.adoc @@ -6,6 +6,7 @@ :source-highlighter: rouge :nofooter: :sectlinks: +:source-language: c++ :leveloffset: +1 diff --git a/doc/hash/combine.adoc b/doc/hash/combine.adoc index a77b1fd..f1cd2b2 100644 --- a/doc/hash/combine.adoc +++ b/doc/hash/combine.adoc @@ -5,7 +5,7 @@ Say you have a point class, representing a two dimensional location: -[listing] +[source] ---- class point { @@ -24,7 +24,7 @@ public: and you wish to use it as the key for an unordered_map. You need to customise the hash for this structure. To do this we need to combine the hash values for x and y. The function `boost::hash_combine` is supplied for this purpose: -[listing,subs="+quotes,+macros"] +[source] ---- class point { @@ -50,7 +50,7 @@ Full code for this example is at link:../../examples/point.cpp[/libs/container_h [NOTE] ==== When using `boost::hash_combine` the order of the calls matters. -[listing,subs="+quotes,+macros"] +[source] ---- std::size_t seed = 0; boost::hash_combine(seed, 1); @@ -58,7 +58,7 @@ boost::hash_combine(seed, 2); ---- results in a different seed to: -[listing,subs="+quotes,+macros"] +[source] ---- std::size_t seed = 0; boost::hash_combine(seed, 2); @@ -71,7 +71,7 @@ If you are calculating a hash value for data where the order of the data doesn't To calculate the hash of an iterator range you can use `boost::hash_range`: -[listing,subs="+quotes,+macros"] +[source] ---- std::vector some_strings; std::size_t hash = boost::hash_range(some_strings.begin(), some_strings.end()); diff --git a/doc/hash/custom.adoc b/doc/hash/custom.adoc index fdbdf5c..7d5c908 100644 --- a/doc/hash/custom.adoc +++ b/doc/hash/custom.adoc @@ -7,7 +7,7 @@ If you have a structure `library::book`, where each book is uniquely defined by its member `id`: -[listing] +[source] ---- namespace library { @@ -29,7 +29,7 @@ namespace library Then all you would need to do is write the function `library::hash_value`: -[listing,subs="+quotes,+macros"] +[source] ---- namespace library { @@ -43,7 +43,7 @@ namespace library And you can now use `boost::hash` with book: -[listing,subs="+quotes,+macros"] +[source] ---- library::book knife(3458, "Zane Grey", "The Hash Knife Outfit"); library::book dandelion(1354, "Paul J. Shanley", diff --git a/doc/hash/portability.adoc b/doc/hash/portability.adoc index b427a38..53ff2e3 100644 --- a/doc/hash/portability.adoc +++ b/doc/hash/portability.adoc @@ -9,7 +9,7 @@ On a strictly standards compliant compiler, an overload defined in the `boost` n Let's say we have a simple custom type: -[list,subs="+quotes,+macros"] +[source] ---- namespace foo { @@ -33,7 +33,7 @@ On a compliant compiler, when `hash_value` is called for this type, it will look So first move the member function out of the class: -[listing,subs="+quotes,+macros"] +[source] ---- namespace foo { @@ -63,7 +63,7 @@ Unfortunately, I couldn't declare `hash_value` as a friend, as some compilers do For compilers which don't support ADL, `hash_value` needs to be defined in the `boost` namespace: -[listing] +[source] ---- #ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP namespace boost diff --git a/doc/hash/ref.adoc b/doc/hash/ref.adoc index e759291..89f637a 100644 --- a/doc/hash/ref.adoc +++ b/doc/hash/ref.adoc @@ -9,7 +9,7 @@ For the full specification, see section 6.3 of the http://www.open-std.org/jtc1/ Defines `boost::hash`, and helper functions. -[listing,subs="+quotes,+macros"] +[source] ---- namespace boost { template struct hash; @@ -125,7 +125,7 @@ namespace boost { ==== Synopsis -[listing,subs="+quotes,+macros"] +[source] ---- // #include @@ -137,7 +137,7 @@ struct hash : public std::unary_function { ==== Description -[listing] +[source] ---- std::size_t operator()(T const& val) const; ---- @@ -161,7 +161,7 @@ Throws:: Only throws if `hash_value(T)` throws. === Synopsis -[listing] +[source] ---- // #include @@ -172,7 +172,7 @@ struct hash { === Description -[listing] +[source] ---- std::size_t operator()(T const val) const; ---- @@ -189,7 +189,7 @@ Throws:: Doesn't throw === hash_combine -[listing] +[source] ---- template void hash_combine(size_t &, T const&); @@ -214,7 +214,7 @@ Throws:: Only throws if `hash_value(T)` throws. Strong exception safety, as long === hash_range -[listing] +[source] ---- template std::size_t hash_range(It, It); @@ -228,7 +228,7 @@ Calculate the combined hash value of the elements of an iterator range. [horizontal] Effects:: For the two argument overload: + -[listing,subs="+quotes,+macros"] +[source] ---- size_t seed = 0; @@ -241,7 +241,7 @@ return seed; + For the three arguments overload: + -[listing,subs="+quotes,+macros"] +[source] ---- for(; first != last; ++first) { @@ -265,7 +265,7 @@ Throws:: Only throws if `hash_value(std::iterator_traits::value_type)` throw === hash_value -[listing] +[source] ---- std::size_t hash_value(bool val); std::size_t hash_value(char val); @@ -357,7 +357,7 @@ Returns:: |`std::pair` a| -[listing] +[source] ---- size_t seed = 0; hash_combine(seed, val.first); @@ -368,7 +368,7 @@ return seed; |`std::tuple` a| -[listing] +[source] ---- size_t seed = 0; hash_combine(seed, get<0>(val)); diff --git a/doc/hash/tutorial.adoc b/doc/hash/tutorial.adoc index 43f5cbd..8a4a9a7 100644 --- a/doc/hash/tutorial.adoc +++ b/doc/hash/tutorial.adoc @@ -7,7 +7,7 @@ When using a hash index with link:../../../multi_index/index.html[Boost.MultiInd If your standard library supplies its own implementation of the unordered associative containers and you wish to use `boost::hash`, just use an extra template parameter: -[listing,subs="+quotes,+macros"] +[source] ---- std::unordered_multiset > set_of_ints; @@ -20,7 +20,7 @@ std::unordered_map > map_int_to_string; To use `boost::hash` directly, create an instance and call it as a function: -[listing,subs="+quotes,+macros"] +[source] ---- #include @@ -34,7 +34,7 @@ int main() For an example of generic use, here is a function to generate a vector containing the hashes of the elements of a container: -[listing,subs="+quotes,+macros"] +[source] ---- template std::vector get_hashes(Container const& x)