[boost] [chrono] Compiler errors for mpl/abs.hpp

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[boost] [chrono] Compiler errors for mpl/abs.hpp

Hello all,

I am trying to compile the example below on MSVC using Boost.Chrono (headers-only) from the sandbox but I am getting some compiler errors.

What am I doing wrong?

Thank you very much.

#include <boost/chrono.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>

int main(int argc, char* argv[]) {
    assert(argc == 2);
    unsigned long n = sqrt(double(atol(argv[1])));

    using boost::phoenix::ref;
    using boost::phoenix::arg_names::_1;

    double sum = 0.0;
    int factor = 1;

    std::vector<double> v(n);
    std::fill(v.begin(), v.end(), 1.0);

    boost::chrono::duration<double> sec;
    for (unsigned long i = 0; i < n; ++i) {
        boost::chrono::system_clock::time_point start =
        std::for_each(v.begin(), v.end(), (
            ref(sum) += factor * _1
        sec += boost::chrono::system_clock::now() - start;
    std::cout << sec.count() << std::endl;

    assert(sum == n * n);
    return 0;

E:\sandbox\boost-sandbox-local\libs\local\example>cl /EHs /Ox /I..\..\.. /I"c:\P
rogram Files\boost\boost_1_46_1" /I..\..\..\..\boost-sandbox-chrono.x benchmark_
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42 for 80x86
Copyright (C) Microsoft Corporation.  All rights reserved.

..\..\..\..\boost-sandbox-chrono.x\boost/mpl/abs.hpp(72) : error C2143: syntax e
rror : missing ',' before ')'
        ..\..\..\..\boost-sandbox-chrono.x\boost/mpl/abs.hpp(75) : see reference
 to class template instantiation 'boost::mpl::abs_impl<boost::mpl::integral_c_ta
g>::apply<N>' being compiled
..\..\..\..\boost-sandbox-chrono.x\boost/mpl/abs.hpp(72) : error C2059: syntax e
rror : ')'
..\..\..\..\boost-sandbox-chrono.x\boost/mpl/abs.hpp(74) : error C2143: syntax e
rror : missing ';' before '{'
..\..\..\..\boost-sandbox-chrono.x\boost/mpl/abs.hpp(75) : error C2143: syntax e
rror : missing ';' before '}'
..\..\..\..\boost-sandbox-chrono.x\boost/mpl/abs.hpp(72) : error C2143: syntax e
rror : missing ';' before '}'
..\..\..\..\boost-sandbox-chrono.x\boost/mpl/abs.hpp(72) : fatal error C1004: un
expected end-of-file found