最近把一些代码拉到了一个新系统,我在编译chrono_io和ratio_io时遇到了一些麻烦。
我不确定要更改什么,因为错误appear to affect the preprocessor。
似乎它必须是代码无法解决的跨平台兼容性问题。
我是如何解决这些预处理程序和编译器错误的?
In file included from Test.cc:12:0:
chrono_io:221:18: error: missing binary operator before token "("
#if __has_feature(cxx_rvalue_references)
^
chrono_io:789:18: error: missing binary operator before token "("
#if __has_feature(cxx_rvalue_references)
^
chrono_io:821:18: error: missing binary operator before token "("
#if __has_feature(cxx_rvalue_references)
^
chrono_io:833:18: error: missing binary operator before token "("
#if __has_feature(cxx_rvalue_references)
^
chrono_io:845:18: error: missing binary operator before token "("
#if __has_feature(cxx_rvalue_references)
^
chrono_io:858:18: error: missing binary operator before token "("
#if __has_feature(cxx_rvalue_references)
^
chrono_io:885:18: error: missing binary operator before token "("
#if __has_feature(cxx_rvalue_references)
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:36:1: error: ‘_LIBCPP_BEGIN_NAMESPACE_STD’ does not name a type
_LIBCPP_BEGIN_NAMESPACE_STD
^
ratio_io:46:1: error: ‘basic_string’ does not name a type
basic_string<_CharT>
^
ratio_io:58:8: error: ‘ratio_string’ is not a class template
struct ratio_string<atto, char>
^
ratio_io:58:21: error: ‘atto’ was not declared in this scope
struct ratio_string<atto, char>
^
ratio_io:58:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:513:47: note: ‘std::atto’
typedef ratio<1, 1000000000000000000> atto;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:59:1: error: explicit specialization of non-template ‘ratio_string’
{
^
ratio_io:60:12: error: ‘string’ does not name a type
static string symbol() {return string(1, 'a');}
^
ratio_io:61:12: error: ‘string’ does not name a type
static string prefix() {return string("atto");}
^
ratio_io:83:8: error: ‘ratio_string’ is not a class template
struct ratio_string<atto, wchar_t>
^
ratio_io:83:21: error: ‘atto’ was not declared in this scope
struct ratio_string<atto, wchar_t>
^
ratio_io:83:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:513:47: note: ‘std::atto’
typedef ratio<1, 1000000000000000000> atto;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:83:34: error: ‘ratio_string’ is not a template type
struct ratio_string<atto, wchar_t>
^
ratio_io:92:8: error: ‘ratio_string’ is not a class template
struct ratio_string<femto, char>
^
ratio_io:92:21: error: ‘femto’ was not declared in this scope
struct ratio_string<femto, char>
^
ratio_io:92:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:514:47: note: ‘std::femto’
typedef ratio<1, 1000000000000000> femto;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:92:32: error: ‘ratio_string’ is not a template type
struct ratio_string<femto, char>
^
ratio_io:117:8: error: ‘ratio_string’ is not a class template
struct ratio_string<femto, wchar_t>
^
ratio_io:117:21: error: ‘femto’ was not declared in this scope
struct ratio_string<femto, wchar_t>
^
ratio_io:117:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:514:47: note: ‘std::femto’
typedef ratio<1, 1000000000000000> femto;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:117:35: error: ‘ratio_string’ is not a template type
struct ratio_string<femto, wchar_t>
^
ratio_io:126:8: error: ‘ratio_string’ is not a class template
struct ratio_string<pico, char>
^
ratio_io:126:21: error: ‘pico’ was not declared in this scope
struct ratio_string<pico, char>
^
ratio_io:126:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:515:47: note: ‘std::pico’
typedef ratio<1, 1000000000000> pico;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:126:31: error: ‘ratio_string’ is not a template type
struct ratio_string<pico, char>
^
ratio_io:151:8: error: ‘ratio_string’ is not a class template
struct ratio_string<pico, wchar_t>
^
ratio_io:151:21: error: ‘pico’ was not declared in this scope
struct ratio_string<pico, wchar_t>
^
ratio_io:151:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:515:47: note: ‘std::pico’
typedef ratio<1, 1000000000000> pico;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:151:34: error: ‘ratio_string’ is not a template type
struct ratio_string<pico, wchar_t>
^
ratio_io:160:8: error: ‘ratio_string’ is not a class template
struct ratio_string<nano, char>
^
ratio_io:160:21: error: ‘nano’ was not declared in this scope
struct ratio_string<nano, char>
^
ratio_io:160:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:516:47: note: ‘std::nano’
typedef ratio<1, 1000000000> nano;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:160:31: error: ‘ratio_string’ is not a template type
struct ratio_string<nano, char>
^
ratio_io:185:8: error: ‘ratio_string’ is not a class template
struct ratio_string<nano, wchar_t>
^
ratio_io:185:21: error: ‘nano’ was not declared in this scope
struct ratio_string<nano, wchar_t>
^
ratio_io:185:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:516:47: note: ‘std::nano’
typedef ratio<1, 1000000000> nano;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:185:34: error: ‘ratio_string’ is not a template type
struct ratio_string<nano, wchar_t>
^
ratio_io:194:8: error: ‘ratio_string’ is not a class template
struct ratio_string<micro, char>
^
ratio_io:194:21: error: ‘micro’ was not declared in this scope
struct ratio_string<micro, char>
^
ratio_io:194:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:517:47: note: ‘std::micro’
typedef ratio<1, 1000000> micro;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:194:32: error: ‘ratio_string’ is not a template type
struct ratio_string<micro, char>
^
ratio_io:219:8: error: ‘ratio_string’ is not a class template
struct ratio_string<micro, wchar_t>
^
ratio_io:219:21: error: ‘micro’ was not declared in this scope
struct ratio_string<micro, wchar_t>
^
ratio_io:219:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:517:47: note: ‘std::micro’
typedef ratio<1, 1000000> micro;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:219:35: error: ‘ratio_string’ is not a template type
struct ratio_string<micro, wchar_t>
^
ratio_io:228:8: error: ‘ratio_string’ is not a class template
struct ratio_string<milli, char>
^
ratio_io:228:21: error: ‘milli’ was not declared in this scope
struct ratio_string<milli, char>
^
ratio_io:228:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:518:47: note: ‘std::milli’
typedef ratio<1, 1000> milli;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:228:32: error: ‘ratio_string’ is not a template type
struct ratio_string<milli, char>
^
ratio_io:253:8: error: ‘ratio_string’ is not a class template
struct ratio_string<milli, wchar_t>
^
ratio_io:253:21: error: ‘milli’ was not declared in this scope
struct ratio_string<milli, wchar_t>
^
ratio_io:253:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:518:47: note: ‘std::milli’
typedef ratio<1, 1000> milli;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:253:35: error: ‘ratio_string’ is not a template type
struct ratio_string<milli, wchar_t>
^
ratio_io:262:8: error: ‘ratio_string’ is not a class template
struct ratio_string<centi, char>
^
ratio_io:262:21: error: ‘centi’ was not declared in this scope
struct ratio_string<centi, char>
^
ratio_io:262:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:519:47: note: ‘std::centi’
typedef ratio<1, 100> centi;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:262:32: error: ‘ratio_string’ is not a template type
struct ratio_string<centi, char>
^
ratio_io:287:8: error: ‘ratio_string’ is not a class template
struct ratio_string<centi, wchar_t>
^
ratio_io:287:21: error: ‘centi’ was not declared in this scope
struct ratio_string<centi, wchar_t>
^
ratio_io:287:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:519:47: note: ‘std::centi’
typedef ratio<1, 100> centi;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:287:35: error: ‘ratio_string’ is not a template type
struct ratio_string<centi, wchar_t>
^
ratio_io:296:8: error: ‘ratio_string’ is not a class template
struct ratio_string<deci, char>
^
ratio_io:296:21: error: ‘deci’ was not declared in this scope
struct ratio_string<deci, char>
^
ratio_io:296:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:520:47: note: ‘std::deci’
typedef ratio<1, 10> deci;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:296:31: error: ‘ratio_string’ is not a template type
struct ratio_string<deci, char>
^
ratio_io:321:8: error: ‘ratio_string’ is not a class template
struct ratio_string<deci, wchar_t>
^
ratio_io:321:21: error: ‘deci’ was not declared in this scope
struct ratio_string<deci, wchar_t>
^
ratio_io:321:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:520:47: note: ‘std::deci’
typedef ratio<1, 10> deci;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:321:34: error: ‘ratio_string’ is not a template type
struct ratio_string<deci, wchar_t>
^
ratio_io:330:8: error: ‘ratio_string’ is not a class template
struct ratio_string<deca, char>
^
ratio_io:330:21: error: ‘deca’ was not declared in this scope
struct ratio_string<deca, char>
^
ratio_io:330:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:521:47: note: ‘std::deca’
typedef ratio< 10, 1> deca;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:330:31: error: ‘ratio_string’ is not a template type
struct ratio_string<deca, char>
^
ratio_io:355:8: error: ‘ratio_string’ is not a class template
struct ratio_string<deca, wchar_t>
^
ratio_io:355:21: error: ‘deca’ was not declared in this scope
struct ratio_string<deca, wchar_t>
^
ratio_io:355:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:521:47: note: ‘std::deca’
typedef ratio< 10, 1> deca;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:355:34: error: ‘ratio_string’ is not a template type
struct ratio_string<deca, wchar_t>
^
ratio_io:364:8: error: ‘ratio_string’ is not a class template
struct ratio_string<hecto, char>
^
ratio_io:364:21: error: ‘hecto’ was not declared in this scope
struct ratio_string<hecto, char>
^
ratio_io:364:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:522:47: note: ‘std::hecto’
typedef ratio< 100, 1> hecto;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:364:32: error: ‘ratio_string’ is not a template type
struct ratio_string<hecto, char>
^
ratio_io:389:8: error: ‘ratio_string’ is not a class template
struct ratio_string<hecto, wchar_t>
^
ratio_io:389:21: error: ‘hecto’ was not declared in this scope
struct ratio_string<hecto, wchar_t>
^
ratio_io:389:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:522:47: note: ‘std::hecto’
typedef ratio< 100, 1> hecto;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:389:35: error: ‘ratio_string’ is not a template type
struct ratio_string<hecto, wchar_t>
^
ratio_io:398:8: error: ‘ratio_string’ is not a class template
struct ratio_string<kilo, char>
^
ratio_io:398:21: error: ‘kilo’ was not declared in this scope
struct ratio_string<kilo, char>
^
ratio_io:398:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:523:47: note: ‘std::kilo’
typedef ratio< 1000, 1> kilo;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:398:31: error: ‘ratio_string’ is not a template type
struct ratio_string<kilo, char>
^
ratio_io:423:8: error: ‘ratio_string’ is not a class template
struct ratio_string<kilo, wchar_t>
^
ratio_io:423:21: error: ‘kilo’ was not declared in this scope
struct ratio_string<kilo, wchar_t>
^
ratio_io:423:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:523:47: note: ‘std::kilo’
typedef ratio< 1000, 1> kilo;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:423:34: error: ‘ratio_string’ is not a template type
struct ratio_string<kilo, wchar_t>
^
ratio_io:432:8: error: ‘ratio_string’ is not a class template
struct ratio_string<mega, char>
^
ratio_io:432:21: error: ‘mega’ was not declared in this scope
struct ratio_string<mega, char>
^
ratio_io:432:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:524:47: note: ‘std::mega’
typedef ratio< 1000000, 1> mega;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:432:31: error: ‘ratio_string’ is not a template type
struct ratio_string<mega, char>
^
ratio_io:457:8: error: ‘ratio_string’ is not a class template
struct ratio_string<mega, wchar_t>
^
ratio_io:457:21: error: ‘mega’ was not declared in this scope
struct ratio_string<mega, wchar_t>
^
ratio_io:457:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:524:47: note: ‘std::mega’
typedef ratio< 1000000, 1> mega;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:457:34: error: ‘ratio_string’ is not a template type
struct ratio_string<mega, wchar_t>
^
ratio_io:466:8: error: ‘ratio_string’ is not a class template
struct ratio_string<giga, char>
^
ratio_io:466:21: error: ‘giga’ was not declared in this scope
struct ratio_string<giga, char>
^
ratio_io:466:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:525:47: note: ‘std::giga’
typedef ratio< 1000000000, 1> giga;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:466:31: error: ‘ratio_string’ is not a template type
struct ratio_string<giga, char>
^
ratio_io:491:8: error: ‘ratio_string’ is not a class template
struct ratio_string<giga, wchar_t>
^
ratio_io:491:21: error: ‘giga’ was not declared in this scope
struct ratio_string<giga, wchar_t>
^
ratio_io:491:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:525:47: note: ‘std::giga’
typedef ratio< 1000000000, 1> giga;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:491:34: error: ‘ratio_string’ is not a template type
struct ratio_string<giga, wchar_t>
^
ratio_io:500:8: error: ‘ratio_string’ is not a class template
struct ratio_string<tera, char>
^
ratio_io:500:21: error: ‘tera’ was not declared in this scope
struct ratio_string<tera, char>
^
ratio_io:500:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:526:47: note: ‘std::tera’
typedef ratio< 1000000000000, 1> tera;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:500:31: error: ‘ratio_string’ is not a template type
struct ratio_string<tera, char>
^
ratio_io:525:8: error: ‘ratio_string’ is not a class template
struct ratio_string<tera, wchar_t>
^
ratio_io:525:21: error: ‘tera’ was not declared in this scope
struct ratio_string<tera, wchar_t>
^
ratio_io:525:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:526:47: note: ‘std::tera’
typedef ratio< 1000000000000, 1> tera;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:525:34: error: ‘ratio_string’ is not a template type
struct ratio_string<tera, wchar_t>
^
ratio_io:534:8: error: ‘ratio_string’ is not a class template
struct ratio_string<peta, char>
^
ratio_io:534:21: error: ‘peta’ was not declared in this scope
struct ratio_string<peta, char>
^
ratio_io:534:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:527:47: note: ‘std::peta’
typedef ratio< 1000000000000000, 1> peta;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:534:31: error: ‘ratio_string’ is not a template type
struct ratio_string<peta, char>
^
ratio_io:559:8: error: ‘ratio_string’ is not a class template
struct ratio_string<peta, wchar_t>
^
ratio_io:559:21: error: ‘peta’ was not declared in this scope
struct ratio_string<peta, wchar_t>
^
ratio_io:559:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:527:47: note: ‘std::peta’
typedef ratio< 1000000000000000, 1> peta;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:559:34: error: ‘ratio_string’ is not a template type
struct ratio_string<peta, wchar_t>
^
ratio_io:568:8: error: ‘ratio_string’ is not a class template
struct ratio_string<exa, char>
^
ratio_io:568:21: error: ‘exa’ was not declared in this scope
struct ratio_string<exa, char>
^
ratio_io:568:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:528:47: note: ‘std::exa’
typedef ratio< 1000000000000000000, 1> exa;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:568:30: error: ‘ratio_string’ is not a template type
struct ratio_string<exa, char>
^
ratio_io:593:8: error: ‘ratio_string’ is not a class template
struct ratio_string<exa, wchar_t>
^
ratio_io:593:21: error: ‘exa’ was not declared in this scope
struct ratio_string<exa, wchar_t>
^
ratio_io:593:21: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/chrono:38:0,
from Test.cc:11:
/usr/include/c++/4.8.2/ratio:528:47: note: ‘std::exa’
typedef ratio< 1000000000000000000, 1> exa;
^
In file included from chrono_io:139:0,
from Test.cc:12:
ratio_io:593:33: error: ‘ratio_string’ is not a template type
struct ratio_string<exa, wchar_t>
^
ratio_io:599:1: error: ‘_LIBCPP_END_NAMESPACE_STD’ does not name a type
_LIBCPP_END_NAMESPACE_STD
^
In file included from Test.cc:12:0:
chrono_io:1164:1: error: ‘_LIBCPP_END_NAMESPACE_STD’ does not name a type
_LIBCPP_END_NAMESPACE_STD
^
Test.cc: In function ‘void RealDataTest()’:
Test.cc:167:12: error: cannot bind ‘std::basic_ostream<char>’ lvalue to ‘std::basic_ostream<char>&&’
std::cout << "Time for n->mostRecent: " << (Clock::now() - start) << std::endl;
^
In file included from /usr/include/c++/4.8.2/iostream:39:0,
from Nearby.cc:9,
from Test.cc:5:
/usr/include/c++/4.8.2/ostream:602:5: error: initializing argument 1 of ‘std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = std::chrono::duration<long int, std::ratio<1l, 1000000000l> >]’
operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x)
^
Test.cc:185:12: error: cannot bind ‘std::basic_ostream<char>’ lvalue to ‘std::basic_ostream<char>&&’
std::cout << "Time for n->deletePost: " << (Clock::now() - start) << std::endl;
^
In file included from /usr/include/c++/4.8.2/iostream:39:0,
from Nearby.cc:9,
from Test.cc:5:
/usr/include/c++/4.8.2/ostream:602:5: error: initializing argument 1 of ‘std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = std::chrono::duration<long int, std::ratio<1l, 1000000000l> >]’
operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x)
^
make: *** [all] Error 1
答案 0 :(得分:2)
几年后我没有使用过这段代码。它正在使用:
#if __has_feature(cxx_rvalue_references)
__seconds_(std::move(__seconds)),
...
检查编译器是否支持rvalue引用(C ++ 11移动语义)。我的建议是假设您拥有C ++ 11(因为您必须拥有<chrono>
并且只需删除__has_feature
和#else
分支。
如果由于某种原因你必须支持没有右值引用的编译器,你可以:
#define __has_feature(x) 0
这将在任何地方选择#else
分支。
__has_feature(cxx_rvalue_references)
是一个铿锵声。
<强>更新强>
更新到此库。
https://howardhinnant.github.io/date/chrono_io.html
它已经简化为仅限流媒体持续时间。