Nested templates vs shift operator

后端 未结 4 2058
再見小時候
再見小時候 2020-12-19 09:31

I have been reading all around about be aware >> as ending of nested template and >> as shift operator...

Now I have tried it i

相关标签:
4条回答
  • 2020-12-19 10:16

    MSVC++2010 supports C++0x feature Right Angle Brackets

    0 讨论(0)
  • 2020-12-19 10:18

    This code works exactly what I want (map of pairs) but I supposed to get some error about >>

    C++0x has fixed this. So if you're not getting any error with MSVS2010, then its no wonder, as MSVS2010 has implemented some of C++0x features.

    Also, even with C++03, many compilers handle such cases, though not required by the Standard(2003).

    0 讨论(0)
  • 2020-12-19 10:21

    C++0x now supports that syntax without errors. Compilers have already started to implement most of these features, so it wouldn't be surprising that the latest Microsoft C++ compiler supports it.

    0 讨论(0)
  • 2020-12-19 10:31

    Be careful because previously good C++03 code may break with compilers supporting this feature.

    MyArray< MyArray<int, 16 >> 2>, 5 > arrayInst;
    

    This would be the fix:

    MyArray< MyArray<int, (16 >> 2)>, 5 > arrayInst;
    
    0 讨论(0)
提交回复
热议问题