
On 14 April 2010 12:44, Chad Seibert <chadseibert@live.com> wrote:
Writing this as SP would look like the following (if I understand SP correctly):
For static polymorphism, you write to provide the interface demanded by the concept; you don't need to derive from anything. Consider the Boost.Random concepts, for instance <http://www.boost.org/doc/libs/1_42_0/libs/random/random-concepts.html>. boost::mt19937 isn't derived from some UniformRandomGenerator class. It just provides the necessarily facilities. In my experiments with hash functions, the nicest parts of generic programming has come from the various constructions used to build algorithms out of primitives. For example, I can write a SHA-512 block hash as merkle_damgard_block_hash< sha2_policy<512>::initialization_vector_generator, davies_meyer_compressor<shacal2_block_cypher<512>, state_adder>, digest_from_state<digest<512>, display_endian::big_word_big_byte> > By building it out of the SHACAL-2 block cypher <http://en.wikipedia.org/wiki/SHACAL> run through the Davies-Meyer construction to produce a One-way Compression Function <http://en.wikipedia.org/wiki/One-way_compression_function#Davies-Meyer> which is used repeatedly in the Merkle–Damgård construction to create the hash function <http://en.wikipedia.org/wiki/Merkle%E2%80%93Damg%C3%A5rd_construction>. There's no BlockCypher class, no OneWayCompressor class, etc. They're just concepts.