c++ 相关问题

C ++是一种通用编程语言。它最初被设计为C的扩展,并保持类似的语法,但现在是一种完全不同的语言。使用此标记来查询有关使用C ++编译器编译的代码的问题。对特定标准版本[C ++ 11],[C ++ 17]等相关问题使用版本特定标记。





unsafe,`noexcept`和无头的访问sTD ::variant`

STD:: variant提供以下访问功能: std :: get_if:将指针换成变体,返回指针转换为替代方案。 模板 auto* std :: get_if(std ::

回答 1 投票 0


回答 1 投票 0

哪个编译器是正确的,如何通过修改朋友声明来解决它;

回答 1 投票 0

在不真实发动机4中的crash crash在内存免费操作过程中crash 4 我正在编辑游戏模拟中的不真实引擎4的运行实例中经历以下崩溃: 在ue4editor-win64-debuggame.e ...

thistion在UE4Editor-win64-debuggame.exe.exe中丢弃0x00007FFD1E29551B(UE4Editor-core.dll):0xc0000005:访问违规违规位置0x0000000000000000000010.

回答 0 投票 0


为什么clang ++链接到GCC?

我有一个简单的“ Hello,World”样式程序,我在FreeBSD上与Clang ++一起编译:

回答 2 投票 0



使用

boost::asio::<..etc etc ..>

回答 1 投票 0

反载 +=运算符,意外结果[重复]

我为学习目的写了我自己的字符串课。我正在尝试使 +=运算符超载,以便可以将字符串加在一起。但是,每当我使用操作员时,Inital对象都保持不变。 ...

回答 1 投票 0

如何使用sys_info成员开始从get_info()收到的sys_seconds折断时间 我正在尝试找出给定的日期是否等于DST过渡日期(DST在当天开始或结束)。我的程序如下 #include“ date/tz.h” #include

#include "date/tz.h" #include <chrono> #include <iostream> template <class Duration> bool is_dst(date::zoned_time<Duration> const& zt) { using namespace date; using namespace std; using namespace chrono; auto info = zt.get_info(); std::cout << "TZ Range start: " << info.begin + info.offset << " range end " << info.end + info.offset << std::endl; auto dst_hours = std::chrono::duration_cast<std::chrono::hours>(info.save); auto dst_minutes = std::chrono::duration_cast<std::chrono::minutes>(info.save - dst_hours); return info.save != minutes{0}; } int main(int argc, char *argv[]) { using namespace date; using namespace std; using namespace chrono; std::string tzname = argv[1]; int yy = std::atoi(argv[2]); int mm = std::atoi(argv[3]); int dd = std::atoi(argv[4]); int h = std::atoi(argv[5]); int m = std::atoi(argv[6]); // Construct a local_time type from the broken-down time local_seconds localTime = date::local_days{date::year{yy}/mm/dd} + std::chrono::hours{h} + std::chrono::minutes{m}; auto tz = locate_zone(tzname); auto dst_on_off = is_dst(zoned_time<std::chrono::seconds>{tz, zt, date::choose::latest}); cout << "input time :" << localTime << " latest=" << dst_on_off << '\n'; } 现在我有以下问题,如果我执行以下方式 ./hh_get_utc_dst_offset“澳大利亚/悉尼” 2025 10 05 01 00 TZ范围开始:2025-04-06 02:00:00范围END END 2025-10-05 02:00:00 输入时间:2025-10-05 01:00:00最新=0 。/hh_get_utc_dst_offset“澳大利亚/悉尼” 2025 10 05 03 00 TZ范围开始:2025-10-05 03:00:00范围END END 2026-04-05 03:00:00 输入时间:2025-10-05 03:00:00最新=1,根据sys_info的文档 “开始和结束字段表明,对于关联的time_zone和time_point,偏移量和abbrev在范围内有效[开始,结束)。”这是什么意思? 在DST关闭其印刷电流范围的第一个执行 在第二个执行中,DST在其打印未来范围内 也是我要将info转换为破碎的时间,我该怎么做?我想比较命令行中给出的日期与从info.being和info.end.end.ind. 因此,根据sys_info的文档,“开始和结束字段表示,对于关联的time_zone和time_point,偏移量和abbrev在范围内生效[begin,end,end)。”这是什么意思? 我相信这是问题的关键。 表达式[begin, end)指“半开”范围。 范围开始并包括begin。 但是范围不包括end。 该范围停止了即时。 这意味着end在.offset上无效,因此该表达式: end 没有有效 较少的错误转换为当地时间的方法是: info.end + info.offset 也是我要将info转换为破碎的时间,我该怎么做?我想比较命令行中给出的日期与从info.being和info.end.end.ind. 您可以将序列时间_point分解为UTC字段或本地字段中的字段。 要确定哪个,首先在[begin, end)或auto tz = zt.get_time_zone(); std::cout << "TZ Range start: " << tz->to_local(info.begin) << " range end " << tz->to_local(info.end) << std::endl; 中分别获得序列时间_point。 修理您想要本地字段,并仅显示sys_time: local_timeinfo.begin具有// First convert the `sys_time` to `local_time`: auto local_begin = tz->to_local(info.begin); // local_begin is a datetime // truncate it to just a date auto local_begin_date = floor<days>(local_begin); // Extract the local time of day from the datetime and date auto local_tod = local_begin - local_begin_date; // Convert local_begin_date to a {y, m, d} data structure year_month_day local_ymd{local_begin_date}; // Convert local_tod to a {h, m, s} data structure hh_mm_ss local_hms{local_tod}; ,year_month_day和.year() 这些返回强烈键入的表示.month(),.day()和year。 这些反过来可以分别明确地施放为month,day和int。 unsigned具有强烈键入表示的the tegtersunsigned,hh_mm_ss和.hours()getters。 这些中的每一个都可以通过.minutes()成员函数转换为积分类型。 在每个阶段,从.seconds(),一直到hoursminutes,每种类型都可以像这样流出: seconds

回答 1 投票 0

ISstd ::屏障在C ++中可用为成员变量,并具有完成成员函数的完成功能?

以下代码编译并在GCC中工作正常: #include #include #include struct类{ class():屏障(1,[this](){oncompletion(); ...

回答 1 投票 0

计算分配的std :: string(以及在std :: vector中使用字符串)

我想计算当我创建值并将值分配给字符串时分配了多少内存。 字符串s =“”; cout<< sizeof(s) << endl; cout << sizeof(s.at(0)) * s.capacity() <...

回答 2 投票 0



最新问题
© www.soinside.com 2019 - 2025. All rights reserved.