-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* This file is part of MCF Gthread. | ||
* Copyright (C) 2022-2024 LH_Mouse. All wrongs reserved. | ||
* | ||
* MCF Gthread is free software. Licensing information is included in | ||
* LICENSE.TXT as a whole. The GCC Runtime Library Exception applies | ||
* to this file. */ | ||
|
||
#include "../mcfgthread/cxx11.hpp" | ||
#include "../mcfgthread/exit.h" | ||
#include <assert.h> | ||
#include <stdio.h> | ||
|
||
#ifdef TEST_STD | ||
# include <thread> | ||
namespace NS = std; | ||
#else | ||
namespace NS = ::_MCF; | ||
#endif | ||
|
||
struct copy_will_throw | ||
{ | ||
copy_will_throw() { } | ||
copy_will_throw(const copy_will_throw&) { throw 42; } | ||
void operator()() { ::std::terminate(); } | ||
}; | ||
|
||
int | ||
main(void) | ||
{ | ||
try { | ||
copy_will_throw t; | ||
NS::thread thr(t); | ||
::std::terminate(); | ||
} | ||
catch(int e) { | ||
NS::this_thread::sleep_for(NS::chrono::seconds(3)); | ||
assert(e == 42); | ||
} | ||
} |