[cfe-dev] #include <chrono> with Clang 3.1

Hadassi, Ofer OHadassi at nds.com
Wed Aug 1 20:45:25 PDT 2012


The errors are:
/usr/include/c++/4.6/chrono:240:10: error: cannot cast from lvalue of type 'const long long' to rvalue reference type 'rep' (aka 'long long &&'); types are not compatible
          : __r(static_cast<rep>(__rep)) { }
                ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.6/chrono:128:13: note: in instantiation of function template specialization 'std::chrono::duration<long long &&, std::ratio<1, 1000000> >::duration<long
      long, void>' requested here
            return _ToDur(static_cast<__to_rep>(__d.count()));
                   ^
/usr/include/c++/4.6/chrono:182:9: note: in instantiation of function template specialization 'std::chrono::__duration_cast_impl<std::chrono::duration<long long &&,
      std::ratio<1, 1000000> >, std::ratio<1, 1>, long long &&, true, true>::__cast<long long, std::ratio<1, 1000000> >' requested here
        return __dc::__cast(__d);
               ^
/usr/include/c++/4.6/chrono:247:10: note: in instantiation of function template specialization 'std::chrono::duration_cast<std::chrono::duration<long long &&, std::ratio<1,
      1000000> >, long long, std::ratio<1, 1000000> >' requested here
          : __r(duration_cast<duration>(__d).count()) { }
                ^
/usr/include/c++/4.6/chrono:466:9: note: in instantiation of function template specialization 'std::chrono::duration<long long &&, std::ratio<1, 1000000> >::duration<long
      long, std::ratio<1, 1000000>, void>' requested here
        return __ct(__lhs).count() < __ct(__rhs).count();
               ^
/usr/include/c++/4.6/chrono:667:7: note: in instantiation of function template specialization 'std::chrono::operator<<long long, std::ratio<1, 1000000>, long long,
      std::ratio<1, 1000000> >' requested here
                    < system_clock::duration::zero(),
                    ^
/usr/include/c++/4.6/chrono:128:13: error: call to implicitly-deleted copy constructor of 'std::chrono::duration<long long &&, std::ratio<1, 1000000> >'
            return _ToDur(static_cast<__to_rep>(__d.count()));
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.6/chrono:182:9: note: in instantiation of function template specialization 'std::chrono::__duration_cast_impl<std::chrono::duration<long long &&,
      std::ratio<1, 1000000> >, std::ratio<1, 1>, long long &&, true, true>::__cast<long long, std::ratio<1, 1000000> >' requested here
        return __dc::__cast(__d);
               ^
/usr/include/c++/4.6/chrono:247:10: note: in instantiation of function template specialization 'std::chrono::duration_cast<std::chrono::duration<long long &&, std::ratio<1,
      1000000> >, long long, std::ratio<1, 1000000> >' requested here
          : __r(duration_cast<duration>(__d).count()) { }
                ^
/usr/include/c++/4.6/chrono:466:9: note: in instantiation of function template specialization 'std::chrono::duration<long long &&, std::ratio<1, 1000000> >::duration<long
      long, std::ratio<1, 1000000>, void>' requested here
        return __ct(__lhs).count() < __ct(__rhs).count();
               ^
/usr/include/c++/4.6/chrono:667:7: note: in instantiation of function template specialization 'std::chrono::operator<<long long, std::ratio<1, 1000000>, long long,
      std::ratio<1, 1000000> >' requested here
                    < system_clock::duration::zero(),
                    ^
/usr/include/c++/4.6/chrono:233:12: note: explicitly defaulted function was implicitly deleted here
        constexpr duration(const duration&) = default;
                  ^
/usr/include/c++/4.6/chrono:349:6: note: copy constructor of 'duration<long long &&, std::ratio<1, 1000000> >' is implicitly deleted because field '__r' is of rvalue
      reference type 'rep' (aka 'long long &&')
        rep __r;
            ^
/usr/include/c++/4.6/chrono:182:9: error: call to implicitly-deleted copy constructor of 'typename enable_if<__is_duration<duration<long long &&, ratio<1, 1000000> >
      >::value, duration<long long &&, ratio<1, 1000000> > >::type' (aka 'std::chrono::duration<long long &&, std::ratio<1, 1000000> >')
        return __dc::__cast(__d);
               ^~~~~~~~~~~~~~~~~
/usr/include/c++/4.6/chrono:247:10: note: in instantiation of function template specialization 'std::chrono::duration_cast<std::chrono::duration<long long &&, std::ratio<1,
      1000000> >, long long, std::ratio<1, 1000000> >' requested here
          : __r(duration_cast<duration>(__d).count()) { }
                ^
/usr/include/c++/4.6/chrono:466:9: note: in instantiation of function template specialization 'std::chrono::duration<long long &&, std::ratio<1, 1000000> >::duration<long
      long, std::ratio<1, 1000000>, void>' requested here
        return __ct(__lhs).count() < __ct(__rhs).count();
               ^
/usr/include/c++/4.6/chrono:667:7: note: in instantiation of function template specialization 'std::chrono::operator<<long long, std::ratio<1, 1000000>, long long,
      std::ratio<1, 1000000> >' requested here
                    < system_clock::duration::zero(),
                    ^
/usr/include/c++/4.6/chrono:233:12: note: explicitly defaulted function was implicitly deleted here
        constexpr duration(const duration&) = default;
                  ^
/usr/include/c++/4.6/chrono:349:6: note: copy constructor of 'duration<long long &&, std::ratio<1, 1000000> >' is implicitly deleted because field '__r' is of rvalue
      reference type 'rep' (aka 'long long &&')
        rep __r;
            ^
/usr/include/c++/4.6/chrono:255:11: error: rvalue reference to type 'long long' cannot bind to lvalue of type 'long long'
        { return __r; }
                 ^~~
/usr/include/c++/4.6/chrono:247:39: note: in instantiation of member function 'std::chrono::duration<long long &&, std::ratio<1, 1000000> >::count' requested here
          : __r(duration_cast<duration>(__d).count()) { }
                                             ^
/usr/include/c++/4.6/chrono:466:9: note: in instantiation of function template specialization 'std::chrono::duration<long long &&, std::ratio<1, 1000000> >::duration<long
      long, std::ratio<1, 1000000>, void>' requested here
        return __ct(__lhs).count() < __ct(__rhs).count();
               ^
/usr/include/c++/4.6/chrono:667:7: note: in instantiation of function template specialization 'std::chrono::operator<<long long, std::ratio<1, 1000000>, long long,
      std::ratio<1, 1000000> >' requested here
                    < system_clock::duration::zero(),
                    ^
/usr/include/c++/4.6/chrono:666:21: error: static_assert expression is not an integral constant expression
      static_assert(system_clock::duration::min()
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.6/chrono:666:21: note: undefined function 'operator<<long long, std::ratio<1, 1000000>, long long, std::ratio<1, 1000000> >' cannot be used in a constant
      expression
/usr/include/c++/4.6/chrono:460:7: note: declared here
      operator<(const duration<_Rep1, _Period1>& __lhs,
      ^
/usr/include/c++/4.6/chrono:141:40: error: cannot cast from lvalue of type 'const intmax_t' (aka 'const long long') to rvalue reference type 'long long &&'; types are not
      compatible
              static_cast<_CR>(__d.count()) / static_cast<_CR>(_CF::den)));
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.6/chrono:182:9: note: in instantiation of function template specialization 'std::chrono::__duration_cast_impl<std::chrono::duration<long long,
      std::ratio<1, 1> >, std::ratio<1, 1000000>, long long &&, true, false>::__cast<long long, std::ratio<1, 1000000> >' requested here
        return __dc::__cast(__d);
               ^
/usr/include/c++/4.6/chrono:679:21: note: in instantiation of function template specialization 'std::chrono::duration_cast<std::chrono::duration<long long, std::ratio<1, 1>
      >, long long, std::ratio<1, 1000000> >' requested here
        return std::time_t(duration_cast<chrono::seconds>
                           ^
/usr/include/c++/4.6/chrono:154:40: error: cannot cast from lvalue of type 'const intmax_t' (aka 'const long long') to rvalue reference type 'long long &&'; types are not
      compatible
              static_cast<_CR>(__d.count()) * static_cast<_CR>(_CF::num)));
                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/4.6/chrono:182:9: note: in instantiation of function template specialization 'std::chrono::__duration_cast_impl<std::chrono::duration<long long,
      std::ratio<1, 1000000> >, std::ratio<1000000, 1>, long long &&, false, true>::__cast<long long, std::ratio<1, 1> >' requested here
        return __dc::__cast(__d);
               ^
/usr/include/c++/4.6/chrono:577:22: note: in instantiation of function template specialization 'std::chrono::duration_cast<std::chrono::duration<long long, std::ratio<1,
      1000000> >, long long, std::ratio<1, 1> >' requested here
        return __time_point(duration_cast<_ToDur>(__t.time_since_epoch()));
                            ^
/usr/include/c++/4.6/chrono:687:9: note: in instantiation of function template specialization 'std::chrono::time_point_cast<std::chrono::duration<long long, std::ratio<1,
      1000000> >, std::chrono::system_clock, std::chrono::duration<long long, std::ratio<1, 1> > >' requested here
        return time_point_cast<system_clock::duration>
               ^
7 errors generated.



________________________________________
From: Howard Hinnant [hhinnant at apple.com]
Sent: Wednesday, August 01, 2012 11:21 PM
To: Hadassi, Ofer
Cc: cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] #include <chrono> with Clang 3.1

On Aug 1, 2012, at 9:46 AM, "Hadassi, Ofer" <OHadassi at nds.com> wrote:

> I am using Clang 3.1 on Ubuntu. Compiling this simple program:
>
> #include <thread>
> int main(int argc, char ** argv)
> {
> retrurn 0;
> }
>
> using the following command line fails:
> clang++ -std=c++11 - test.cpp
>
> The failure is due to the inclusion of <chrono> from <thread>. Replacing the
> #include <thread>
> with
> #include <chrono>
> gives the same results.
>
> Is there a way to work with std::thread using Clang?

<thread> needs <chrono> to support these two functions:

template <class Clock, class Duration>
void sleep_until(const chrono::time_point<Clock, Duration>& abs_time);

template <class Rep, class Period>
void sleep_for(const chrono::duration<Rep, Period>& rel_time);

What is the error you're seeing?

Howard


________________________________

This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster at nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes.
To protect the environment please do not print this e-mail unless necessary.

An NDS Group Limited company. www.nds.com




More information about the cfe-dev mailing list