Mario Emmenlauer created THRIFT-5816:
----------------------------------------

             Summary: Fix UUID for boost 1.86.0 (change in {{data}} member 
usage)
                 Key: THRIFT-5816
                 URL: https://issues.apache.org/jira/browse/THRIFT-5816
             Project: Thrift
          Issue Type: Bug
          Components: C++ - Library
    Affects Versions: 0.20.0
            Reporter: Mario Emmenlauer
            Assignee: Carel


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:
{code}
  TUuid(const boost::uuids::uuid& buuid) noexcept
  {
    std::copy(std::begin(buuid.data), std::end(buuid.data), 
std::begin(this->data_));
  }
{code}

The error I get with clang 18 on Ubuntu 22.04 is:
{code}
[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]       |                                     ^
{code}

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:
{code}
  TUuid(const boost::uuids::uuid& buuid) noexcept
  {
    std::copy(std::begin(buuid), std::end(buuid), std::begin(this->data_));
  }
{code}

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

Opinions?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to