www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Generate crc lookup table Dlang style

Hi,
While solving a unrelated programming problem I ended up copying
a CRC16-CCITT implementation Google found for me. After I thought
it would be nice to make a D style implementation with some
compile time magic.
My idea was to implement something similar to:
http://www.ross.net/crc/download/crc_v3.txt
http://www.zorc.breitbandkatze.de/crctester.c
generating the CRC lookup table compile time.

Now. For me it seems like this it should be possible to be
accomplished with the following function definition:
T[] generate_crc_table(T)(T polynomial, T initialValue, bool
refin)
Here is a Gist with my attempt:
https://gist.github.com/NVolcz/8635416

Where does crchighbit come from, I'm missing something?
Could there possibly be a D programmer somewhere out there with
the expertise to help me?
Jan 26 2014