Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <utility>
- #include <memory>
- #include <cstdio>
- template<auto F> struct caller {
- template<class... Ts>
- auto operator()(Ts&&... ts) const
- noexcept(noexcept(F(std::forward<Ts>(ts)...)))
- {
- return F(std::forward<Ts>(ts)...);
- }
- };
- int main()
- {
- using fileptr = std::unique_ptr<std::FILE, caller<std::fclose>>;
- static_assert(sizeof(fileptr) == sizeof(FILE*));
- fileptr ptr(std::fopen("xyz.txt", "w"));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement