这是我试图编译的代码,从某个地方的另一个论坛得到它.
// to_string example
#include <iostream> // std::cout
#include <string> // std::string, std::to_string
int main ()
{
std::string pi = "pi is " + std::to_string(3.1415926);
std::string perfect = std::to_string(1+2+4+7+14) + " is a perfect number";
std::cout << pi << '\n';
std::cout << perfect << '\n';
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我收到错误:'to_string'不是'std'的成员
我已经在其他论坛中阅读选择标志"让g ++遵循c ++ 11 ISO语言标准[-std = c ++ 11]"并且我拥有它仍然不起作用.
任何帮助将不胜感激
我正在使用GNU GCC编译器和代码:: Blocks 12.11
Tl; dr:我想要一个选项类,它的成员使用不可为空的类型,没有默认值。
C# 8.0 引入了可空引用类型。
我发现在 ASP.Net选项模式中使用可为空的引用类型相当困难、不完整,或者我遗漏了一些东西。我遇到了这个stack over flow post 中描述的相同问题。
- 我们不想让 Name 可以为空,因为我们需要在任何地方进行传统的空检查(这违背了不可空引用类型的目的)
- 我们无法创建构造函数来强制使用不可为空的名称值创建 MyOptions 类,因为 Configure 方法为我们构造了选项实例
- 我们不能使用 null-forgiving 操作符技巧 (public string name { get; set; } = null!;) 因为这样我们就不能确保 Name 属性被设置,我们最终会在 Name 属性中得到一个空值不会出现这种情况的地方(在服务内部)
我想要一个选项类,它的成员使用不可为空的类型,没有默认值。无论如何,该帖子中的答案最终都使用可空类型(我试图避免)或默认值(我也试图避免)。
关于选项验证的评论提出了好点,看起来很有希望,但事实证明该Validate方法仍然需要一个选项对象来验证,如果您已经必须将选项对象传递给它,这将违背目的。
public ValidateOptionsResult Validate(string name, MyOptions options)
// Pointless if MyOptions options is being passed in here
Run Code Online (Sandbox Code Playgroud)
这是毫无意义的,因为我已经确定强制使用所有不可为空成员且没有默认值的选项类的唯一方法是使用构造函数。以下面的代码示例为例。
public ValidateOptionsResult Validate(string name, MyOptions options)
// Pointless if MyOptions options is being passed …Run Code Online (Sandbox Code Playgroud) 我已经构建了一个 Vuejs 单页面应用程序,我想添加用户可切换的动态主题。用户在某处或某处有一个按钮,他们可以单击“浅色”或“深色”主题选项,整个应用程序会立即更新。我还想让所有“主题”scss 文件都位于本地。
这里的答案是迄今为止我找到的最接近的答案,但主题不是本地的。
const themes = {
flatly: "https://bootswatch.com/4/flatly/bootstrap.min.css",
materia: "https://bootswatch.com/4/materia/bootstrap.min.css",
solar: "https://bootswatch.com/4/solar/bootstrap.min.css"
};
Run Code Online (Sandbox Code Playgroud)
如果我能弄清楚如何让这个答案与本地主题文件一起使用,那就太好了,但是用本地路径切换链接路径是行不通的。
const themes = {
dark: "dark-theme.scss",
light: "light-theme.scss"
};
Run Code Online (Sandbox Code Playgroud)
我怀疑这不起作用,因为 Webpack 或其他一些不包含 scss 文件的编译问题。
我发现如果我将以下内容添加到我的 index.html 中,我可以让我的主题文件出现在客户端源中,
<link rel="stylesheet" type="text/css" href="<%= BASE_URL %>dark-theme.scss">
但是我不知道如何在我的应用程序中引用它。也许像这样的链接http://localhost:8080/dark-theme.scss?但我认为这在生产中不起作用(而且它在本地也不起作用)。
我也看过:
我也尝试过import "@/path/to/theme.scss";在我的main.ts文件中做一些确实有效的事情,但我不知道如何利用它来使主题可切换。它只是在我的头上添加了一个如下所示的元素,该元素没有 id 或类,因此我无法有效地查询它以将其切换出来。使用require也可以做类似的事情。
<style type="text/css" >
...
</style>
Run Code Online (Sandbox Code Playgroud) I am trying to add google authentication to my vue.js front end. This is a new project created through the CLI with typescript and component style syntax enabled (along with others) and also has a corresponding back end web server. I have been following this guide from google but I am very new to vue and gapi. I don't know how to load <script src="https://apis.google.com/js/platform.js" async defer></script> into my app or how to use it once loaded. I've found examples …
javascript google-authentication typescript vue.js vue-component
javascript ×2
vue.js ×2
asp.net ×1
asp.net-core ×1
c# ×1
c++ ×1
c++11 ×1
css ×1
gcc ×1
html ×1
stl ×1
typescript ×1
webpack ×1