Compartilhar via


bit_and Function

A predefined function object that performs the bitwise AND operation (binary operator&) on its arguments.

template<class Type = void>
    struct bit_and : public binary_function<Type, Type, Type> {
        Type operator()(
            const Type& Left, 
            const Type& Right
        )   const;
    };

// specialized transparent functor for operator&
template<>
   struct bit_and<void>
   {
      template<class Type1, class Type2>
      auto operator()(Type1&& Left, Type2&& Right) const
         -> decltype(std::forward<Type1>(Left)
            & std::forward<Type2>(Right));
   };

Parameters

  • Type, Type1, Type2
    Any type that supports an operator& that takes operands of the specified or inferred types.

  • Left
    The left operand of the bitwise AND operation. The unspecialized template takes an lvalue reference argument of type Type. The specialized template does perfect forwarding of lvalue and rvalue reference arguments of inferred type Type1.

  • Right
    The right operand of the bitwise AND operation. The unspecialized template takes an lvalue reference argument of type Type. The specialized template does perfect forwarding of lvalue and rvalue reference arguments of inferred type Type2.

Return Value

The result of Left&Right. The specialized template does perfect forwarding of the result, which has the type that's returned by operator&.

Remarks

The bit_and functor is restricted to integral types for the basic data types, or to user-defined types that implement binary operator&.

Requirements

Header: <functional>

Namespace: std

See Also

Reference

<functional>

Lvalues and Rvalues

Standard Template Library