google / butteraugli

butteraugli estimates the psychovisual difference between two images
Apache License 2.0
1.96k stars 137 forks source link

VS 2017 does not accept ConstRestrict #28

Open DominikWitczakAMD opened 7 years ago

DominikWitczakAMD commented 7 years ago

The compilation error is:

1>butteraugli.h(137): error C2219: syntax error: type qualifier must be after '*' 1>butteraugli.h(258): error C2219: syntax error: type qualifier must be after '*' 1>butteraugli.h(258): note: see reference to alias template instantiation 'ConstRestrict<ComponentType*>' being compiled 1>butteraugli.h(302): note: see reference to class template instantiation 'butteraugli::Image<ComponentType>' being compiled

It looks like somebody has already done some research on this issue here: https://stackoverflow.com/questions/42869470/should-msvc-reject-an-templated-using-without-instantiation . From what they're saying, it seems like it's a genuine flaw in the code but I haven't had time to dig into the C++ spec.

A simple workaround for this glitch is changing the alias declaration to something along the lines of:

using ConstRestrict = T const;

JackBoosY commented 5 years ago

Hi @DominikWitczakAMD, it's a MSVC known bug, and you can use using ConstRestrict = T const; instead.

See issue here.