C++ Library Extensions 2022.12.09
To help learn modern C++ programming
022-noexcept.cpp
Go to the documentation of this file.
1#include <tpf_output.hpp>
2
3struct dummy_type{};
4
5template<auto FuncType, typename... ArgTypes>
6constexpr bool is_noexcept_v = noexcept(FuncType(std::declval<ArgTypes>()...));
7
8int sum(int a, int b) noexcept
9{
10 return a + b;
11}
12
13template<typename T>
14T pro(T a, T b) noexcept
15{
16 return a * b;
17}
18
19template<auto FuncPtr, typename... ArgTypes>
20constexpr auto func_ptr_t = FuncPtr<ArgTypes...>;
21
23{
25
26 stream << is_noexcept_v<sum, int, int> << tpf::endl;
27
28 constexpr auto pro_func = pro<int>;
29
30 stream << pro_func(1, 2) << tpf::endl;
31
32 stream << is_noexcept_v<pro_func, int, int> << tpf::endl;
33
34}
35
36int main()
37{
39}
constexpr bool is_noexcept_v
Definition: 022-noexcept.cpp:6
T pro(T a, T b) noexcept
void example_is_noexcept()
constexpr auto func_ptr_t
int main()
int sum(int a, int b) noexcept
Definition: 022-noexcept.cpp:8
tpf::sstream stream
constexpr auto endl
Definition: tpf_output.hpp:973
Stream output operators << are implemented.