{求助}boost库tuple_comparison.hpp报warning

2 views
Skip to first unread message

WindyWinter

unread,
Oct 31, 2009, 8:13:50 AM10/31/09
to pon...@googlegroups.com
一直用的是boost1.34,现在要升级到boost1.38,结果原本没有任何问题的代码爆出warning来了:
/usr/local/include/boost-1_38/boost/tuple/tuple_comparison.hpp:73: 警告: 建议在 || 的操作数中出现的 && 前后加上括号
查tuple_comparison.hpp的73行,1.34和1.38是一样子的,都是:
template<class T1, class T2>
inline bool lt(const T1& lhs, const T2& rhs) {
  return lhs.get_head() < rhs.get_head()  ||
            !(rhs.get_head() < lhs.get_head()) &&
            lt(lhs.get_tail(), rhs.get_tail());         <-第73行
}
两个版本的operator <定义也是一样的:
template<class T1, class T2, class S1, class S2>
inline bool operator<(const cons<T1, T2>& lhs, const cons<S1, S2>& rhs)
{
  // check that tuple lengths are equal
  BOOST_STATIC_ASSERT(length<T2>::value == length<S2>::value);

  return detail::lt(lhs, rhs);
}
其实整个tuple_comparison.hpp都是一个样子的。

boost的maillist上有一个相关的讨论:http://lists.boost.org/Archives/boost/2009/02/147717.php ,认为这是个bug。
确实看写法不像会有问题,但是我却想不通为什么1.34版本没有warning,1.38却会有warning(编译时都有-Wall)。

Soli Deo gloria,
yours WindyWinter
and http://www.briefdream.com
Reply all
Reply to author
Forward
0 new messages