Compile-time constant CRCs

I didn't tag this because I'm not sure if it should belong to
[preprocessor], [mpl] or [crc].
Given the black-box (macro, function, class, whatever) I'll call ConstCRC32
that is assignable to a unsigned int is there a way to write:
unsigned int hash = ConstCRC32( "HELLO" );
and have an optimized build yield the equivalent of:
unsigned int hash = 0x58a10fc0;
I had a solution (although obviously non-portable) in msvc7.1 but after
moving to msvc8 and stepping through the code I noticed that msvc8's
"improved" optimizing compiler cannot optimize away the calculation like
msvc7.1's could. I also doubt that the code would work if I ever had to
port it to another compiler.
I tried using simple TMP techniques I've used in the past but couldn't find
a way to access the characters of the string.
So looking around I came upon boost.crc which is geared towards computing
crcs of blocks of data which isn't really what I care about right now.
I also found boost.mpl which is very cool but I have a hard time grasping
still.
The problems seems solvable with mpl if I could transform the data into
boost::mpl::list_c
participants (1)
-
Michael Marcin