3 ms·
I just found this statement from Microsoft: https://blogs.msdn.microsoft.com/vcblog/2017/09/11/two-phase-name-lookup-support-comes-to-msvc/ https://blogs.msdn.
by TwoBit 8y ago
I just found this statement from Microsoft:
https://blogs.msdn.microsoft.com/vcblog/2017/09/11/two-phase-name-lookup-support-comes-to-msvc/ https://blogs.msdn.microsoft.com/vcblog/2017/09/11/two-phase...
"MSVC previously recorded the body of the template as a stream of tokens and stored that stream away to be replayed at instantiation time. The behavior of MSVC’s template substitution from a recorded token stream somewhat resembled the behavior of macro substitution in that limited analysis was done of a template’s body."
- userbinator 8y agoAs someone who is admittedly not an expert in template metaprogramming by any means, thinking of templates as an extension of macros feels like the intuitive and simpler way compared to the more complex two-phase algorithm, so it's no surprise that MSVC did it too... then again, I prefer simpler languages (like C) and see the difficulty of implementing the standard as a sign that its complexity may be too high.
- TwoBit 8y agoThere's a reason why templates work like this. If they didn't work like this then template specializations that you write can break somebody else's code which is dependent on the template behaving a certain way.