描述
它是一個按位或函數對象類和二元函數對象類,其調用返回在其兩個參數之間應用按位 "or" 運算的結果(由運算符 | 返回)。
聲明
以下是 std::bit_or 的聲明。
template <class T> struct bit_or;
C++11
template <class T> struct bit_or;
參數
T- 它是函數調用的參數和返回類型的類型。
返回值
空
異常
noexcep- 它不會拋出任何異常。
示例
在下麵的例子中解釋了 std::bit_or。
#include <iostream>
#include <functional>
#include <numeric>
#include <iterator>
int main () {
int flags[] = {10,20,40,80,160,320,640,1280};
int acc = std::accumulate (flags, std::end(flags), 0, std::bit_or<int>());
std::cout << "accumulated:" << acc << '\n';
return 0;
}
讓我們編譯並運行上麵的程序,這將產生以下結果 -
accumulated:2046
相關用法
- C# bit_xor用法及代碼示例
- C# bit_and用法及代碼示例
- C# Decimal.FromOACurrency()用法及代碼示例
- C# Int32.CompareTo用法及代碼示例
- C# UInt64.ToString()用法及代碼示例
- C# Type.GetTypeHandle()用法及代碼示例
- C# Uri.IsBaseOf()用法及代碼示例
- C# String.ToUpperInvariant用法及代碼示例
- C# File.Copy(String, String, Boolean)用法及代碼示例
- C# Uri.IsHexEncoding()用法及代碼示例
- C# Char.TryParse()用法及代碼示例
- C# Math Cosh()用法及代碼示例
- C# Int64.Equals用法及代碼示例
- C# Convert.ToInt16(String, IFormatProvider)用法及代碼示例
- C# DateTimeOffset.FromUnixTimeMilliseconds()用法及代碼示例
- C# StringBuilder.ToString用法及代碼示例
- C# DateTimeOffset.AddMinutes()用法及代碼示例
- C# MathF.Log10()用法及代碼示例
- C# TimeSpan Subtract()用法及代碼示例
- C# Math.Floor()用法及代碼示例
注:本文由純淨天空篩選整理自 C++ Functional Library - bit_or。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。