forked from Mq-b/Loser-HomeWork
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ninter6.cpp
56 lines (48 loc) · 908 Bytes
/
Ninter6.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <cstdio>
#include <vector>
inline void dbg(const char* msg)
{
std::puts(msg);
std::fflush(stdout);
}
struct X {
X() noexcept
{
dbg("X()");
};
~X() noexcept
{
dbg("~X()");
};
X(const X&)
{
dbg("X(const X&)");
}
X(X&&) noexcept
{
dbg("X(X&&)");
}
};
auto make_vector(auto&&...args) {
return std::vector<std::common_type_t<decltype(args)...>>{std::forward<decltype(args)>(args)...};
}
void test()
{
static_assert(requires {
{
make_vector(std::vector{1, 2, 3})
} -> std::same_as<std::vector<std::vector<int>>>;
{
make_vector(1, 2, 3)
} -> std::same_as<std::vector<int>>;
make_vector(1, 2, 3).size() == 3;
});
X x1;
X x2;
auto vec = make_vector(x1, std::move(x2));
}
int main()
{
test();
dbg("test end");
}