MPTL example: how to use the MPTL for STL algorithms

The sequential code with the STL:

#include <iostream>
#include <deque>
#include <algorithm>
using namespace std;
 
template <typename Iterator>
void print_elements(Iterator first, Iterator last, char* msg)
{
    cout << msg;
    for ( ; first != last; ++first) {
        cout << *first << " ";
    }
    cout << endl;
}
 
int main()
{
    deque<int> coll1;
 
    for (int i = 1; i <= 9; ++i) {
        coll1.push_back(i);
    }
 
    print_elements(coll1.begin(), coll1.end(), "");
    deque<int> coll2(coll1.size());
 
 
    transform(coll1.begin(),
              coll1.end(),
              coll2.begin(),
              negate<int>());
 
    print_elements(coll2.begin(), coll2.end(), "");
 
    replace_if(coll2.begin(), coll2.end(),
               bind2nd(less<int>(), -5), 10);
 
    print_elements(coll2.begin(), coll2.end(), "");
}

The parallel code, using the MPTL:

#include "mptl.h"
#include "mptl_algo.h"
 
int main()
{
    deque<int> coll1;
 
    mptl::setNumThreads(4);
 
    for (int i = 1; i <= 9; ++i) {
        coll1.push_back(i);
    }
 
    print_elements(coll1.begin(), coll1.end(), "");
    deque<int> coll2(coll1.size());
 
    mptl::execute(mptl::transform(coll1.begin(),
                  coll1.end(),
                  coll2.begin(),
                  negate<int>()));
 
    print_elements(coll2.begin(), coll2.end(), "");
 
    mptl::execute(mptl::replace_if(coll2.begin(), coll2.end(),
                  bind2nd(less<int>(), -5), 10));
 
    print_elements(coll2.begin(), coll2.end(), "");
}