描述
它是一個按位 AND 函數對象類和二元函數對象類,其調用返回在其兩個參數之間應用按位 "and" 運算的結果(由運算符 & 返回)。
聲明
以下是 std::bit_and 的聲明。
template <class T> struct bit_and;
C++11
template <class T> struct bit_and;
參數
T- 它是函數調用的參數和返回類型的類型。
返回值
空
異常
noexcep- 它不會拋出任何異常。
示例
在下麵的例子中解釋了 std::bit_and。
#include <iostream>
#include <functional>
#include <algorithm>
#include <iterator>
int main () {
int values[] = {1000,2000,3000,4000,5000};
int masks[] = {0xf,0xf,0xf,255,255};
int results[5];
std::transform (values, std::end(values), masks, results, std::bit_and<int>());
std::cout << "results:";
for (const int& x:results)
std::cout << ' ' << x;
std::cout << '\n';
return 0;
}
讓我們編譯並運行上麵的程序,這將產生以下結果 -
8 0 8 160 136
相關用法
- C# bit_xor用法及代碼示例
- C# bit_or用法及代碼示例
- 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_and。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。