鉴于Windows API函数GetGlyphIndices()可以将2字节UNICODE字符代码转换为字形索引,我打算硬编码那些字形索引,而不是UNICODE点.那可能吗 ?
我知道MS稍后可以为一个特定的UNICODE点更改此函数返回的值,但我希望在这种情况下当前的字形索引将保留在字形集中.
换句话说,我的理解是,如果MS决定将新的字形索引与UNICODE点相关联,它将放大保留旧字形的字形集.
有人能证实吗?
在第3章:C++之旅:抽象机制的第82页中,作者写道:
如果我们还想为Vector使用range-for循环,我们必须定义合适的begin()和end()函数:
template<typename T>
T? begin(Vector<T>& x)
{
return &x[0]; // pointer to ?rst element
}
template<typename T>
T? end(Vector<T>& x)
{
return x.begin()+x.size(); // pointer to one-past-last element
}
Run Code Online (Sandbox Code Playgroud)
鉴于这些,我们可以写:
void f2(const Vector<string>& vs) // Vector of some strings
{
for (auto s : vs)
cout << s << ’\n’;
}
Run Code Online (Sandbox Code Playgroud)
请注意,类模板Vector在草稿的第81页中定义.
第§8.3.5/ 8段(强调我的):
如果参数的类型包括"指向T的未知边界的数组的指针"或"对T的未知边界的数组的引用"形式的类型,则该程序是不正确的.函数不应具有类型数组或函数的返回类型,尽管它们可能具有类型指针的返回类型或对此类事物的引用.虽然可以有函数指针数组,但是不应该有函数数组.
§8.5.3/ 5的要点(5.2.1)和(5.2.1.1)(重点是我的):
(5.2.1) - 如果是初始化表达式
(5.2.1.1) - 是xvalue(但不是位字段),类prvalue, 数组prvalue或函数lvalue,"cv1 T1"与"cv2 T2"引用兼容,或者
如果我对我的假设(在标题中)错了,我会很感激有一个产生prvalue数组的例子.
A union can have member functions (including constructors and destructors), but it shall not have virtual ([class.virtual]) functions. A union shall not have base classes. A union shall not be used as a base class. If a union contains a non-static data member of reference type the program is ill-formed. [?Note: Absent default member initializers ([class.mem]), if any non-static data member of a union has a non-trivial default constructor ([class.default.ctor]), copy constructor, move constructor ([class.copy.ctor]), copy assignment operator, move …
临时对象的实现通常会尽可能延迟,以避免创建不必要的临时对象。
[注3:临时对象具体化:
(2.1) 将引用绑定到纯右值时 ([dcl.init.ref], [expr.type.conv], [expr.dynamic.cast], [expr.static.cast], [expr.const.cast] , [expr.cast]),
(2.2) 对类纯右值 ([expr.ref], [expr.mptr.oper]) 执行成员访问时,
(2.3) 当对数组纯右值 ([conv.array], [expr.sub]) 执行数组到指针的转换或下标时,
(2.4)std?::?initializer_list<T>从花括号初始化列表([dcl.init.list])初始化类型对象时,
(2.5) 对于某些未计算的操作数 ([expr.typeid], [expr.sizeof]),和
(2.6) 当具有非cv 类型的纯右void值出现为丢弃值表达式 ([expr.prop]) 时。
— 尾注]
在§7.5(C++ 14)的例子中,我发现:
enum {}; // ill-formed
但是,从技术上讲,我认为代码是有效的.enum {}是一个枚举说明符,因此,它是一个类型说明符,它是一个decl-specifier,因此,它是一个带有省略的init-declarator-list的简单声明.这被§7.5接受.请注意,对于未作用域的枚举,标识符是可选的.此外,clang编译此警告.
编辑
关于提到的答案the *decl-specifier-seq* shall introduce one or more names into the program, or shall redeclare a name introduced by a previous declaration,我在下面展示了一个编译的typedef声明,但是其decl-specifier-seq在声明中没有引入任何名称:
typedef class {} A;
Run Code Online (Sandbox Code Playgroud)