initializing std vector at compile time

0

I have the following code running but how do I now initialize a vector or variable with it.

constexpr uint32_t _RtlComputeCrc32(
    _In_  DWORD dwInitial,
    _In_reads_bytes_(stLength)    const BYTE *pbyData,
    _In_  INT stLength
)
{
    ULONG crc = 0xFFFFFFFF;

    while (stLength-- != 0)
    {
        pbyData++;
      //  crc = ((crc >> 8) & 0x00FFFFFF) ^ crc32_table[(crc ^ *(pbyData++)) & 0x000000FF];
    }
    return crc ^ 0xFFFFFFFF;
}

constexpr uint32_t crccalc(const std::wstring_view field)
{
    return _RtlComputeCrc32(0, (BYTE*)field.data(), (INT)field.size() * sizeof(wchar_t));
}

template<const wchar_t* T >
struct crcfield
{
    //static constexpr const std::wstring_view  sname = T;
    static constexpr const uint32_t field = crccalc(T);
};

struct Field
{
    std::wstring_view namee;
    static const uint32_t crcfield;
};

If I want a static variable now how must this looks like:

static constexpr const wchar_t *namee = _T("test");

auto f = crcfield**<???>;**

If I for example do the following:

 auto f = crcfield<_T("t")>;

I get the error:

 error C2762: 'crcfield': invalid expression as a template argument for 'T'
c++
templates
c++17
stdvector
asked on Stack Overflow Jan 28, 2019 by makurisan • edited Jan 28, 2019 by Konrad Rudolph

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0