Changes between Version 4 and Version 5 of SoC2016


Ignore:
Timestamp:
Jan 11, 2016, 9:44:28 AM (7 years ago)
Author:
Niall Douglas
Comment:

slight improvements to project idea

Legend:

Unmodified
Added
Removed
Modified
  • SoC2016

    v4 v5  
    138138==== Programming competency test ====
    139139Write a function which uses one of the compile time string hashing techniques at https://stackoverflow.com/questions/2111667/compile-time-string-hashing
    140 to generate a constexpr `std::array<unsigned>` of its input strings. The function ought to have the following
     140(or a constexpr hash function of your preference) to generate a constexpr `std::array<unsigned>` of its input strings. The function ought to have the following
    141141prototype:
    142142
     
    145145template<class... Strings> constexpr std::array<unsigned, sizeof...(Strings)> hash_strings(Strings&&... strings);
    146146
    147 // Example of usage
    148 constexpr std::array<unsigned, 4> string_hashes = hash_strings("google", "summer", "of", "code");
     147// Examples of usage
     148constexpr std::array<unsigned, 0> string_hashes0 = hash_strings();
     149constexpr std::array<unsigned, 2> string_hashes2 = hash_strings("niall", "douglas");
     150constexpr std::array<unsigned, 4> string_hashes4 = hash_strings("google", "summer", "of", "code");
     151// This should fail elegantly and usefully ...
     152//constexpr std::array<unsigned, 0> string_hashes_fail = hash_strings(5);
    149153}}}
     154
     155In your submission you should:
     156
     1571. Explain why you chose the constexpr string hash function you did and the strengths of your choice over other choices.
     1582. Test that the output is identical whether executed by the compiler at compile time, or at runtime.
     1593. '''Prove''' that the compile time constexpr implementation generates no runtime code whatsoever.
    150160
    151161Submission of the programming test should be via copying and pasting the code you wrote into the end of the proposal you submit to Google Melange.