Hi,@tashman
std::binary_function is in header file functional
.
You could test the sample below.
I am using Version: VS2022 Preview. C++ 14. MSVC: 14.38.32919.
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
struct same : std::binary_function<int, int, bool>
{
bool operator()(int a, int b) const { return a == b; }
};
int main()
{
std::vector<char> v1{ 'A', 'B', 'C', 'D', 'E' };
std::vector<char> v2{ 'E', 'D', 'C', 'B', 'A' };
std::vector<bool> v3(v1.size());
std::transform(v1.begin(), v1.end(), v2.begin(), v3.begin(), std::not2(same()));
std::cout << std::boolalpha;
for (std::size_t i = 0; i < v1.size(); ++i)
std::cout << v1[i] << " != " << v2[i] << " : " << v3[i] << '\n';
}
Best regards,
Minxin Yu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.