小编SHA*_*BAZ的帖子

使用函数对象的C ++线程,如何调用多个析构函数,而不是构造函数?

请在下面找到代码片段:

class tFunc{
    int x;
    public:
    tFunc(){
        cout<<"Constructed : "<<this<<endl;
        x = 1;
    }
    ~tFunc(){
        cout<<"Destroyed : "<<this<<endl;
    }
    void operator()(){
        x += 10;
        cout<<"Thread running at : "<<x<<endl;
    }
    int getX(){ return x; }
};

int main()
{
    tFunc t;
    thread t1(t);
    if(t1.joinable())
    {
        cout<<"Thread is joining..."<<endl;
        t1.join();
    }
    cout<<"x : "<<t.getX()<<endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

我得到的输出是:

Constructed : 0x7ffe27d1b0a4
Destroyed : 0x7ffe27d1b06c
Thread is joining...
Thread running at : 11
Destroyed : 0x2029c28
x : 1
Destroyed : 0x7ffe27d1b0a4 …
Run Code Online (Sandbox Code Playgroud)

c++ multithreading destructor

12
推荐指数
2
解决办法
520
查看次数

如何自定义 Material UI Tab 的指示器宽度和位置

我正在使用Material ui 的选项卡,并且能够对选项卡的指示器进行更改。但是,我正在尝试使用样式将指示器的宽度减小到每个选项卡的固定宽度。但似乎指标的位置靠左并带有一些计算值,并且给它一个宽度不会使指标居中对齐。找不到合适的解决方案,请帮助我。这是可编辑的CodeSandbox

找到以下片段:

  1. 默认全角标签。指标占据基本按钮的全宽: 项目清单

  2. 指示器的宽度固定,但未与选项卡标签下方的中心对齐。 项目清单

tabs styling indicator material-ui

1
推荐指数
1
解决办法
1850
查看次数