fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <memory>
  4.  
  5. using namespace std;
  6.  
  7. template<class T, class F, F f>
  8. struct static_deleter{
  9. void operator()(T* p){ f(p); }
  10. };
  11.  
  12. int main()
  13. {
  14. using ptr = unique_ptr<FILE, static_deleter<FILE, decltype(&fclose), &fclose>>;
  15. cout << sizeof(FILE*) << endl;
  16. cout << sizeof(ptr(fopen("file","w"))) << endl;
  17. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
4
4