简体   繁体   中英

operator== and explicit constructor in boost::detail::atomic_count?

I found that boost::detail::atomic_count doesn't have the declaration and definition for operator==().

So if I have the following: boost::detail::atomic_count i(0); if (i == 0) { // do something } boost::detail::atomic_count i(0); if (i == 0) { // do something }

Questions

  1. Since boost::detail::atomic_count has an explicit constructor, it seems like the 0 in the if-statement won't be used as an parameter of the constructor?
  2. There is no operator== defined and declared; how does the compiler compare i to zero?

Thanks in advance.

PS The code is compiled and run fine with gcc 4.6.2 and boost 1.47. on Linux.

查看源代码可以发现boost::detail::atomic_count隐式转换为long ,用于相等性比较。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM