Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5816

Fix UUID for boost 1.86.0 (change in {{data}} member usage)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.20.0
    • 0.21.0
    • C++ - Library
    • None
    • Patch Available

    Description

      I have just updated boost to 1.86.0 (current latest), and thrift to current latest master. Now the UUID support does not build for me. I can see that a relevant change was in the PR for this issue, but I don't know for sure if boost 1.86.0 is part of the breaking change.

      The following code does not build for me:

        TUuid(const boost::uuids::uuid& buuid) noexcept
        {
          std::copy(std::begin(buuid.data), std::end(buuid.data), std::begin(this->data_));
        }
      

      The error I get with clang 18 on Ubuntu 22.04 is:

      [build] /data/tmp/Debug/thrift/lib/cpp/src/thrift/TUuid.h:93:15: error: no matching function for call to 'begin'
      [build]    93 |     std::copy(std::begin(buuid.data), std::end(buuid.data), std::begin(this->data_));
      [build]       |               ^~~~~~~~~~
      [build] /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/initializer_list:90:5: note: candidate template ignored: could not match 'initializer_list<_Tp>' against 'data_type'
      [build]    90 |     begin(initializer_list<_Tp> __ils) noexcept
      [build]       |     ^
      [build] /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/range_access.h:52:5: note: candidate template ignored: substitution failure [with _Container = const data_type]: no member named 'begin' in 'boost::uuids::uuid::data_type'
      [build]    52 |     begin(_Container& __cont) -> decltype(__cont.begin())
      [build]       |     ^                                            ~~~~~
      [build] /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/range_access.h:63:5: note: candidate template ignored: substitution failure [with _Container = data_type]: no member named 'begin' in 'boost::uuids::uuid::data_type'
      [build]    63 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      [build]       |     ^                                                  ~~~~~
      [build] /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/range_access.h:95:5: note: candidate template ignored: could not match '_Tp[_Nm]' against 'const data_type'
      [build]    95 |     begin(_Tp (&__arr)[_Nm]) noexcept
      [build]       |     ^
      [build] /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/range_access.h:113:31: note: candidate template ignored: could not match 'valarray<_Tp>' against 'const data_type'
      [build]   113 |   template<typename _Tp> _Tp* begin(valarray<_Tp>&) noexcept;
      [build]       |                               ^
      [build] /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/range_access.h:114:37: note: candidate template ignored: could not match 'const valarray<_Tp>' against 'const data_type'
      [build]   114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      [build]       |                                     ^
      

      I think the reason is that according to https://www.boost.org/doc/libs/1_86_0/libs/uuid/doc/html/uuid.html#changes_changes_in_boost_1_86_0_major_update, the use of the data member is now discouraged, and does not work in all cases any more. So it seems this broke with boost 1.86.0, but I'm not sure how well earlier boost versions supported this.

      I'm not really knowledgeable with boost::uuids. But according to a quick search, the iterators are available directly on the uuid, instead of the data member?! So the following compiles for me:

        TUuid(const boost::uuids::uuid& buuid) noexcept
        {
          std::copy(std::begin(buuid), std::end(buuid), std::begin(this->data_));
        }
      

      Highlight: Remove the .data from buuid in two places.

      Opinions?

      Attachments

        Activity

          People

            cjcombrink Carel
            emmenlau Mario Emmenlauer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1.5h
                1.5h