草庐IT

internal_init

全部标签

c++ - 为了使用 Glib::wrap,必须 Glib::init()'ed 什么?

所以我正在尝试使用GtkSourceViewmm在C++中使用GtkSourceView,其文档和支持水平给我的印象是很长一段时间没有仔细研究它。但我始终是一个乐观主义者:)我正在尝试添加SourceView使用一些类似于以下的代码:Glib::RefPtrsource_language_manager=gtksourceview::SourceLanguageManager::create();Glib::RefPtrsource_language=Glib::wrap(gtk_source_language_manager_guess_language(source_languag

c++ - init-declarators 的完整表达式的定义

在init-declarator的情况下完整表达式的定义据说“包括”初始化程序的组成表达式,以及应用的任何转换/隐式调用的函数(构造函数)。这意味着完整表达式甚至不需要是表达式,这没有意义,因为它被称为一个(初始化声明符不是表达式)。进一步在标准中,完整的表达式被用作表达式,那么如果它可以包含不相交的表达式,甚至不是表达式的东西,那有什么意义呢?无论如何,我的主要问题是为什么不总是表达式的完整表达式被视为表达式?这应该如何运作? 最佳答案 Thismeansthatafull-expressionneednotevenbeanexp

c++ - "internal linkage"是什么意思?

在标准中它说:Whenanamehasinternallinkage,theentityitdenotescanbereferredtobynamesfromotherscopesinthesametranslationunit.和:Anamehavingnamespacescope(3.3.6)hasinternallinkageifitisthenameof—avariable,functionorfunctiontemplatethatisexplicitlydeclaredstatic;因此请考虑以下代码:#includenamespaceA{/*awithinternalli

c++ - std::begin 如何推导 braced-init-list 的类型?

以下代码失败:templatevoidfunc(T&t){}intmain(){func({1,2,3});}但是对于autoa={1,2,3};它是有效的,因为规则允许auto推导出一个std::initializer_list。std::begin如何编写以允许std::begin({1,2,3})工作? 最佳答案 std::begin({1,2,3})有效是因为std::begin有一个overloadtakinganstd::initializer_list. 关于c++-std

c++ - 这是未定义的行为还是 struct init 的错误?

请考虑这段代码:#includeintmain(){structA{intx;inty;intz;intfoo(){std::coutxyzxyzx=1;this->z=10;return2;}};Ab{b.foo(),b.z=b.moo(),3};std::cout我的VS2017(x64版本)中的结果:enterfoo:0,0,0entermoo:5,0,0final:1,2,3ideone.com(gcc6.3)的结果https://ideone.com/OGqvjW):enterfoo:0,0,3entermoo:5,0,3final:1,2,2一个编译器立即将z成员设置为3,

c++ - 链接错误 : undefined reference to EVP_CIPHER_CTX_ and EVP_CIPHER_CTX_init

我在我的代码中使用了crypto++。我不想使用它的依赖项,所以我尝试在我的文件夹中导入crypto++文件并将它们包含在我的.cpp文件中我有以下错误:TEST.cpp:(.text+0x89a0):undefinedreferenceto`EVP_CIPHER_CTX_init'TEST.cpp:(.text+0x8cb0):undefinedreferenceto`EVP_aes_128_cbc'TEST.cpp:(.text+0x8cdd):undefinedreferenceto`EVP_CipherInit_ex'TEST.cpp:(.text+0x8d49):undefi

c++ - 分配器 : how are the standard containers expected to work internally?

作为这个问题的示例,我将使用std::vector。它的定义来自documentation如下:template>class vector;正如预期的那样,如果T是它的类型,分配器应该偏向于T。总之,下面的代码编译没有错误(至少,使用GCC)并运行:#include#include#includestructS{inti;doubled;std::strings;};intmain(){std::allocatoralloc;std::vector>v{alloc};v.push_back(S{});}在这里,我通过使用专注于int的分配器创建vector的S。它是合法的代码吗?我应该

c++ - P0960,在 c++20 中是否有任何类型的机制来检测新聚合 init 中是否有 ()s 缩小?

与P0960“允许从带括号的值列表初始化聚合”,您也可以使用()进行聚合初始化。但是,此初始化允许缩小,而{}不允许。#include#includestructFoo{intx,y;};intmain(){//autop=newFoo{INT_MAX,UINT_MAX};//stillwon'tcompileautoq=newFoo(INT_MAX,UINT_MAX);//c++20allowsnarrowingaggregatesinitstd::vectorv;//v.emplace_back(Foo{INT_MAX,UINT_MAX});//stillwon'tcompilev

c++ - 具有负大小的 Google Mock testing::internal::ReturnAction<R> 数组

我有测试代码可以做类似的事情EXPECT_CALL(mock,getSomeString()).WillOnce(Return(&testString));其中getSomeString()通过引用返回:std:string&getSomeString();得到../../../../src/test/unit/gmock/gmock-actions.h:Inmemberfunction‘testing::internal::ReturnAction::operatortesting::Action()const[withF=conststd::string&(),R=std::bas

c++ - iterator_traits<InIter>::value_type 的创建是否会在传递时触发遵从? (异常测试)

我在故意为不特别遵守迭代器的函数抛出异常(出于测试目的)时遇到了麻烦。要了解我在做什么,请带上我的decorator_iterator结构:structdecorated_iterator:boost::iterator_adaptor,BaseIterator,boost::use_default,IteratorTag>{//....private:friendclassboost::iterator_core_access;/*usedtothrowanexceptionupondereference*/typenamebase_type::referencedereferenc