静态断言声明可能出现在块作用域(作为块声明)和类体内(作为成员声明)
好的,现在我有以下代码:
struct foo_t
{
static constexpr std::size_t maxAlignment()
{
// This is just a sample; I removed real code from this method.
return std::max(alignof(__m128), __alignof(__m256));
}
static_assert(0 == ((maxAlignment() -1) & maxAlignment()), "some message");
};
Run Code Online (Sandbox Code Playgroud)
MSVC 2015和Intel C++ 16.0.2都没有编译此代码(前者显示"错误C2131:表达式未评估为常量",后者显示"函数调用必须在常量表达式中具有常量值"错误并指向调用maxAlignmentin static_assert).
但MSVC 2015 Update 1 确实编译了以下代码,而英特尔C++ 16.0.2 则没有:
template <typename T, std::size_t Alignment>
struct foo_t
{
static constexpr std::size_t maxAlignment()
{
return std::max(std::alignment_of<T>::value, Alignment);
}
static_assert(0 == ((maxAlignment() -1) & …Run Code Online (Sandbox Code Playgroud) 我有一个桌面应用程序,其中所有窗口(HWND)使用Direct2D 1.1自行渲染.我的问题是如何更正确地做到这一点?
每个窗口是否都有自己的Direct2D设备上下文派生自一个Direct2D设备?在这种情况下,我无法在没有额外技巧的情况下在子窗口上呈现透明内容(我必须在父窗口的上下文中更改目标,将父窗口呈现为Direct2D位图,然后在子目标上绘制此位图).
也许最好有一个Direct2D设备上下文,所有窗口都呈现自己?我相信DirectComposition以类似的方式工作.不幸的是,我无法使用它,因为我的目标是Windows 7.