axmolengine / axmol

Axmol Engine – A Multi-platform Engine for Desktop, XBOX (UWP) and Mobile games. (A fork of Cocos2d-x-4.0)
https://axmol.dev
MIT License
868 stars 195 forks source link

Compilation error when using VS2022 v17.8.0 #1435

Closed rh101 closed 10 months ago

rh101 commented 10 months ago

image

It seems that _String_iter_types has been updated to remove redundant template parameters: https://github.com/microsoft/STL/commit/45111bbc67c58fd3a5d7e172f8eb29c80c750ff6#diff-47339b57101941628ad9f2c5369af8928f218a6716d304e14b7480dcc84392f6

It seems to work if the code in ntcvt.hpp is changed from this:

namespace detail
{
// different with resize, not all of fill new memory with '\0'
template <class _Elem, class _Traits = std::char_traits<_Elem>,
          class _Alloc = std::allocator<_Elem>>
class intrusive_string : public std::basic_string<_Elem, _Traits, _Alloc>
{
public:
#if _MSC_VER >= 1920 // VS2019+
  using _Alty        = std::_Rebind_alloc_t<_Alloc, _Elem>;
  using _Alty_traits = std::allocator_traits<_Alty>;

  using _Scary_val = std::_String_val<
      std::conditional_t<std::_Is_simple_alloc_v<_Alty>, std::_Simple_types<_Elem>,
                         std::_String_iter_types<
                             _Elem, typename _Alty_traits::size_type,
                             typename _Alty_traits::difference_type, typename _Alty_traits::pointer,
                             typename _Alty_traits::const_pointer, _Elem&, const _Elem&>>>;
#endif

to this:

namespace detail
{
// different with resize, not all of fill new memory with '\0'
template <class _Elem, class _Traits = std::char_traits<_Elem>,
          class _Alloc = std::allocator<_Elem>>
class intrusive_string : public std::basic_string<_Elem, _Traits, _Alloc>
{
public:
#if _MSC_VER >= 1935 // VS2022 v17.8.0+
  using _Alty        = std::_Rebind_alloc_t<_Alloc, _Elem>;
  using _Alty_traits = std::allocator_traits<_Alty>;

  using _Scary_val = std::_String_val<
      std::conditional_t<std::_Is_simple_alloc_v<_Alty>, std::_Simple_types<_Elem>,
                         std::_String_iter_types<
                             _Elem, typename _Alty_traits::size_type,
                             typename _Alty_traits::difference_type, typename _Alty_traits::pointer,
                             typename _Alty_traits::const_pointer>>>;
#elif _MSC_VER >= 1920 // VS2019+
  using _Alty        = std::_Rebind_alloc_t<_Alloc, _Elem>;
  using _Alty_traits = std::allocator_traits<_Alty>;

  using _Scary_val = std::_String_val<
      std::conditional_t<std::_Is_simple_alloc_v<_Alty>, std::_Simple_types<_Elem>,
                         std::_String_iter_types<
                             _Elem, typename _Alty_traits::size_type,
                             typename _Alty_traits::difference_type, typename _Alty_traits::pointer,
                             typename _Alty_traits::const_pointer, _Elem&, const _Elem&>>>;
#endif
aismann commented 10 months ago

Edit: I get the same error with VS 17.8.0 and fix works

rh101 commented 10 months ago

Thanks for confirming!

halx99 commented 10 months ago

@rh101 could you create a PR?

rh101 commented 10 months ago

@rh101 could you create a PR

Create a PR against this project or is there another repository I should log it against for the thirdparty ntcvt?

halx99 commented 10 months ago

you can create PR for this repo only