最終更新日時:
が更新

履歴 編集

function template
<utility>

std::constant_wrapper::operator|(C++26)

template <constexpr-param L, constexpr-param R>
friend constexpr auto operator|(L x, R y) noexcept;

概要

2つのconstant_wrapperが保持する値のビット論理和をおこなう。

戻り値

constant_wrapper<(L::value | R::value)>{}を返す。

備考

  • Hidden friendsとして定義されるため、引数依存の名前探索 (ADL) でのみ発見される。
  • オペランドのいずれかがconstant_wrapperでない場合、保持する値へアンラップして通常の演算がおこなわれる。

#include <utility>
#include <type_traits>

int main()
{
  // オペランドがすべてconstant_wrapperなので、結果もconstant_wrapperになる
  auto x = std::cw<6> | std::cw<1>;
  static_assert(x == 7);
  static_assert(std::is_same_v<decltype(x), std::constant_wrapper<7>>);
}

出力


バージョン

言語

  • C++26

処理系

関連項目

参照