我们使用CDynamicAccessor继承自CAccessorBase. 该函数MoveNext会抛出
HRESULT MoveNext() throw()
但没有说明它是什么异常类型。我怎么知道?
I Foo bar DNA
我想,以取代DNA用D.N.A(D.N.A.也就是OK),但不是要取代"我"和"富".
我有一些线索,但都失败了.
string s = "I Foo bar DNA";
cout << std::regex_replace(s, std::regex("([A-Z]){2,}"), "$1.") << endl;
//output: I Foo bar A.
Run Code Online (Sandbox Code Playgroud)
要么
cout << std::regex_replace(s, std::regex("([A-Z])[A-Z]"), "$1.") << endl;
//output: I Foo bar D.A
Run Code Online (Sandbox Code Playgroud) 有 std::is_trivially_copyable 的演示代码 https://en.cppreference.com/w/cpp/types/is_trivially_copyable
void test()
{
struct A {
int m;
A(const A& o):m(o.m){}
};
struct D {
int m;
D(D const&) = default; // -> trivially copyable
D(int x) : m(x + 1) {}
};
std::cout << std::is_trivially_copyable<A>::value << '\n';
std::cout << std::is_trivially_copyable<D>::value << '\n';
}
Run Code Online (Sandbox Code Playgroud)
A 是不可复制的,但 D 可以。我使用默认行为实现 A 的复制构造函数。是什么造成了这种差异?
std::array<int, 3> foo = {1,2,3};
int bar[] = {1,2,3}; // the size is 3
Run Code Online (Sandbox Code Playgroud)
对于普通数组,我不必分配大小。但我必须为std::array. 为什么?
我想使用预处理器命令来控制代码执行路径。因为这样可以节省运行时间。
#if (sizeof(T)==1 不符合错误:C1017
template<typename T>
class String
{
public:
static void showSize()
{
#if (sizeof(T)==1)
cout << "char\n";
#else
cout << "wchar_t\n";
#endif
}
};
inline void test()
{
String<char>::showSize();
String<wchar_t>::showSize();
}
Run Code Online (Sandbox Code Playgroud)