xtensor-stack / xtensor

C++ tensors with broadcasting and lazy computing
BSD 3-Clause "New" or "Revised" License
3.32k stars 396 forks source link

fix template disambiguation syntax on MSVC #2799

Open PerretB opened 2 months ago

PerretB commented 2 months ago

MSCV currently emits a syntax error on line (TBB with SIMD branch) https://github.com/xtensor-stack/xtensor/blob/8c0a484f04eccd0dbc0e25eb58a97de000fb048b/include/xtensor/xassign.hpp#L1252

Adds a simple syntax helper for MSVC (not sure what the standard says here).

res_stepper.template store_simd<>(fct_stepper.template step_simd<value_type>()); 

FIXES #2736 (note that compiling with /Zc:lambda on MSVC is currently required to avoid this compiler bug https://developercommunity.visualstudio.com/t/lambda-fails-to-implicitly-capture-constexpr-value/610504 )

spectre-ns commented 2 months ago

I've been wondering how to fix this. The default lambda parser is definitely not compliant with constexpr captures. How did you know that adding <> would fix this?

PerretB commented 2 months ago

I had a vague memory of having encountered a similar problem with the template keyword before, but I can't say I knew it would work :D

spectre-ns commented 2 months ago

Thanks! This will help my code base.

@JohanMabille please review! 🙂

brccabral commented 4 days ago

Hi, Line 1177 has the same .template usage. For my project this change solved the error.