我正在尝试使用收缩来适应#container。它可以完美地工作,直到它包含的元素换行为止。这会使其扩展到 180 像素。
#screen-dimensions
{
width: 250px;
height: 100px;
background-color: yellow;
}
#container
{
display: table;
background-color: pink;
border: 5px solid red;
}
#container > div
{
display: inline-block;
width: 160px;
background-color: lightblue;
border: 5px solid blue;
}Run Code Online (Sandbox Code Playgroud)
<div id="screen-dimensions">
<div id="container">
<div>content</div>
<div>content</div>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
我明白为什么会出现这种行为,但我无法找到任何解决方法。
这可以解决吗?
在溢出标志的情况下,似乎访问此标志将是跨架构编程的一大福音.它将提供一种安全的替代方法来依赖未定义的行为来检查有符号整数溢出,例如:
if(a < a + 100) //detect overflow
Run Code Online (Sandbox Code Playgroud)
我确实知道有安全的替代方案,例如:
if(a > (INT_MAX - 100)) //detected overflow
Run Code Online (Sandbox Code Playgroud)
但是,似乎C和C++语言都缺少对状态寄存器或其中各个标志的访问.为什么不包含此功能或做出哪些语言设计决定禁止包含此功能?
我试图防止线程在特定范围内时中断.但是,使用boost::this_thread::disable_interruption di()似乎没有任何影响.
#include <boost/thread.hpp>
#include <iostream>
void worker() {
std::cout << "START" << std::endl;
for(;;) {
{
boost::this_thread::disable_interruption di();
try {
boost::this_thread::sleep(boost::posix_time::seconds(1));
}
catch(boost::thread_interrupted & e) {
assert( false );
}
}
try {
boost::this_thread::interruption_point();
}
catch(boost::thread_interrupted & e) {
break;
}
}
std::cout << "END" << std::endl;
}
int main() {
boost::thread thread(&worker);
thread.interrupt();
thread.join();
}
Run Code Online (Sandbox Code Playgroud)
文档似乎暗示boost::this_thread::sleep()不会抛出boost::thread_interrupted,而di在范围内.
我究竟做错了什么?