标签: visual-c++-2019

std::strong_ordering 如何仅在零时工作?

我只是研究一个三路比较操作<=>。我看到它返回std::strong_ordering。但是,我无法理解编译器如何仅0在比较运算符(so<0,但不是so<1)中进行限制

#include<compare>
int main()
{
  std::strong_ordering so = 55 <=> 10;

  so < 0; // Fine
  so < 1; // Fails
}
Run Code Online (Sandbox Code Playgroud)

同样,so>20也行不通。以下也不起作用:

constexpr int Zero = 0;
so == Zero; // Error
so == 0; // Fine
Run Code Online (Sandbox Code Playgroud)

编辑- 有趣的观察(在 MSVC 编译器上)。以下是有效的:

so < nullptr

c++ g++ c++20 visual-c++-2019

6
推荐指数
1
解决办法
422
查看次数

没有可显示所选项目的数据源

我目前遇到以下问题。

\n

当前配置:

\n

Microsoft Visual Studio Community 2019 版本 16.8.0 预览版 3.2

\n

Microsoft Visual Studio 社区 2019 版本 16.7.5

\n

(注:以上两个版本都会出现该问题。)

\n

微软 Visual C++ 2019 (00435-60000-00000-AA566)

\n

微软.NET框架版本4.8.03752

\n

微软 Windows 10 专业版 18363

\n

SQL Server 数据工具 (16.0.62009.04150)

\n

VS Workload:使用 C++ 进行桌面开发

\n

问题描述:

\n

我将 dataGridView 组件放置在表单上。当我尝试将数据源添加到 dataGridView 时,\xe2\x80\x9cAdd New Data Source\xe2\x80\x9d 选项显示为灰色。

\n

截图如下:

\n

没有可显示所选项目的数据源

\n

无数据源

\n

注意:我可以通过服务器资源管理器中的数据连接成功地将数据连接添加到本地 SQL Express 实例。

\n

我已经多次卸载并重新安装 VS Community 2019 版本 16.7.5。我目前使用 VS Community 2019 …

datagridview visual-c++-2019

6
推荐指数
0
解决办法
1092
查看次数

VC2019:编译器错误、std::pair 错误或模糊功能

下面的代码使应用程序崩溃或打印出乱码。如果基类的初始化被替换为str_int{ string{V}, 0}那么它就可以正常工作。似乎与一些在线编译器一起工作得很好。

#include <iostream>
#include <utility>

using namespace std;

using str_int = pair<string, int>;

template< const char* V > 
struct C : public str_int
{
  C() : str_int{ V, 0} {}
};

constexpr const char str[] = "abc";

int main()
{
  // works fine
  str_int si{str, 0};
  cout << si.first;

  // crashes the application or prints gibberish
  C<str> c;
  cout << c.first;
}
Run Code Online (Sandbox Code Playgroud)

c++ c++17 visual-c++-2019

6
推荐指数
1
解决办法
113
查看次数

使用 std::chrono::from_stream() 解析时间格式“DD/MM/YYYY at hh:mm:ss”及其他格式

我目前正在尝试解析日志文件中列出的有关实验开始时间的一些信息。读取文件中的重要信息(例如列标题、开始时间、测量之间的时间)后,使用<regex>.

我正在尝试使用该std::chrono::from_stream(...)函数将格式为“DD/MM/YYYY at hh:mm:ss”的字符串解析为std::chrono::time_point字符串示例:

2021 年 8 月 3 日 09:37:25

目前,我正在尝试使用以下函数,该函数尝试从提供的要解析的字符串和要解析的字符串构造持续时间,然后将其转换为 time_point,以便我可以控制所使用的时钟:

#include <chrono>
#include <string>
#include <sstream>
#include <iostream>

using nano = std::chrono::duration<std::uint64_t, std::nano>;

template <typename Duration>
Duration TimeFormat(const std::string& str,
                    const std::string& fmt,
                    const Duration& default_val)
{
    Duration dur;
    std::stringstream ss{ str };
    std::chrono::from_stream(ss, fmt.c_str(), dur);

    /*
    from_stream sets the failbit of the input stream if it fails to parse
    any part of the input format string or if it receives …
Run Code Online (Sandbox Code Playgroud)

c++ c++-chrono c++20 visual-c++-2019

5
推荐指数
1
解决办法
1079
查看次数

标签 统计

visual-c++-2019 ×4

c++ ×3

c++20 ×2

c++-chrono ×1

c++17 ×1

datagridview ×1

g++ ×1