The bit_or is an inbuilt function in C++ which is used to perform bitwise_or and return the result after applying the bitwise_or operation on it’s arguments.
template <class T> struct bit_or;
Parameters: It accepts a parameter T which is the type of the argument to be compared by the functional call.
- Objects of this class can be used on standard algorithms such as transform or accumulate.
- Member functions ( ‘operator()’ ) returns the bitwise_or of its arguments.
We must include the library ‘functional’ and ‘algorithm’ to use bit_or and transform() respectively.
Below is the illustration of bit_or in C++:
Results: -3 2 5 101 1029
Some points to Remember
- Bitwise_or of a number with zero results into the number itself.
- Bitwise_or of two same numbers is also equal to that number itself
- If the number is odd it’s bit_or with 1 will result into same number
- If the number is even it’s bit_or with 1 will always results into “number+1”
Results: 15 1103
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- std::less in C++ with Examples
- cin get() in C++ with Examples
- Pi(π) in C++ with Examples
- std::unary_negate() in C++ with Examples
- SDL library in C/C++ with examples
- exception::what() in C++ with Examples
- std::equal_to in C++ with Examples
- std::is_copy_constructible in C++ with Examples
- Map of Vectors in C++ STL with Examples
- basic_istream::get() in C++ with Examples
- std::has_virtual_destructor in C++ with Examples
- std::is_trivially_destructible in C++ with Examples
- std::is_nothrow_default_constructible in C++ with Examples
- ratio_equal() in C++ with examples
- std::add_const in C++ with Examples
- std::is_literal_type in C++ with Examples
- std::is_trivially_constructible in C++ with Examples
- std::is_copy_assignable in C++ with Examples
- std::is_default_constructible in C++ with Examples
- std::is_move_assignable C++ with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.