Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.83 KB | None | 0 0
  1. #include <utility>
  2. #include <memory>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. #pragma warning(disable:4100)
  7. #pragma warning(disable:4702)
  8.  
  9. struct CReturnReference
  10. {
  11.     template <typename tf_CReturn>
  12.     operator tf_CReturn && () const
  13.     {
  14.         return reinterpret_cast<tf_CReturn &&>(*((tf_CReturn *)nullptr));
  15.     }
  16.  
  17.     template <typename tf_CReturn>
  18.     operator tf_CReturn &() const
  19.     {
  20.         return reinterpret_cast<tf_CReturn &>(*((tf_CReturn *)nullptr));
  21.     }
  22. };
  23.  
  24. class CNullFunctionImpl
  25. {
  26.     static CReturnReference const & fs_GetReference()
  27.     {
  28.         return *((CReturnReference const *)nullptr);
  29.     }
  30. public:
  31.  
  32.     template <typename ...tp_CParams>
  33.     CReturnReference const & operator ()(tp_CParams && ...p_Params) const volatile
  34.     {
  35.         throw "Null call";
  36.         return fs_GetReference();
  37.     }
  38. };
  39.  
  40. void CallFunctionMove(std::unique_ptr<int> &&_UniquePointer)
  41. {
  42. }
  43. void CallFunctionMoveConst(std::unique_ptr<int> const &&_UniquePointer)
  44. {
  45. }
  46. void CallFunctionMoveVolatile(std::unique_ptr<int> volatile &&_UniquePointer)
  47. {
  48. }
  49. void CallFunctionMoveConstVolatile(std::unique_ptr<int> const volatile &&_UniquePointer)
  50. {
  51. }
  52.  
  53. void CallFunction(std::unique_ptr<int> &_UniquePointer)
  54. {
  55. }
  56. void CallFunctionConst(std::unique_ptr<int> const &_UniquePointer)
  57. {
  58. }
  59. void CallFunctionVolatile(std::unique_ptr<int> volatile &_UniquePointer)
  60. {
  61. }
  62. void CallFunctionConstVolatile(std::unique_ptr<int> const volatile &_UniquePointer)
  63. {
  64. }
  65.  
  66. int main()
  67. {
  68.     CNullFunctionImpl Impl;
  69.  
  70.     try
  71.     {
  72.         CallFunction(Impl());
  73.         CallFunctionConst(Impl());
  74.         CallFunctionVolatile(Impl());
  75.         CallFunctionConstVolatile(Impl());
  76.  
  77.         CallFunctionMove(Impl());
  78.         CallFunctionMoveConst(Impl());
  79.         CallFunctionMoveVolatile(Impl());
  80.         CallFunctionMoveConstVolatile(Impl());
  81.     }
  82.     catch (char const *_pException)
  83.     {
  84.         cout << "Error: " << _pException << endl;
  85.     }
  86.  
  87.     return 0;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement