0

why constexpr fails for tydeid

Refer code below: https://www.sololearn.com/en/compiler-playground/cWMZQf1R2563 test function works perfectly fine and no issue about it. Now if I have typeid function which is evaluated at compile time (unlike dynamic_cast). So, if typeid is compile time evaluation, why testnew function fails to compile (To observe this compilation failure, uncomment function call of last two lines in main function)?

29th Jan 2025, 6:50 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
1 Réponse
0
Yes, using std::future and std::promise in C++ can be part of multithreaded code, but they don’t create threads on their own. • If you’re using std::async(...), then a new thread may be created depending on the policy (std::launch::async or deferred). • If you’re using std::promise and manually setting the value in another thread, then you are responsible for creating the thread using std::thread. Example: std::promise<int> p; std::future<int> f = p.get_future(); std::thread t([&p]() { p.set_value(42); // this runs in a separate thread }); int value = f.get(); // blocks in main thread until value is set t.join(); Here: • The set_value is run in a separate thread.
16th Apr 2025, 3:37 PM
Ebrahim Hany
Ebrahim Hany - avatar