首页 > 解决方案 > Postcondition: this->get_id()==thread::id() in Boost

问题描述

In reading the thread management section of the Boost documentation, I see the following under "Default Constructor":

Postconditions:
this->get_id()==thread::id()

I understand that this->get_id() returns the current thread's ID, but what does thread::id() do? I can't seem to find thread::id() in the documentation.

What is the meaning of Postconditions?

I had originally understood Postconditions to be return values, but that understanding doesn't make sense with the default constructor documentation.

标签: c++multithreadingboost

解决方案


thread::id()thread::id是使用默认构造函数构造的类型的对象。默认构造的 id 对象不代表线程,所有默认构造的 id 对象比较相等。简而言之,对象的默认构造thread函数创建一个不代表执行线程的对象。


推荐阅读