• Source
    1. #include <iostream>
    2. using namespace std;
    3.  
    4. class MySingleClassInstance
    5. {
    6. public:
    7. static MySingleClassInstance&& GetInstance()
    8. {
    9. static MySingleClassInstance instance;
    10. return std::move(instance);
    11. };
    12.  
    13. MySingleClassInstance(const MySingleClassInstance& other) = delete;
    14. MySingleClassInstance() noexcept = default;
    15. MySingleClassInstance(MySingleClassInstance&& other) noexcept = default;
    16. MySingleClassInstance& operator=(const MySingleClassInstance& other) = delete;
    17. MySingleClassInstance& operator=(MySingleClassInstance&& other) noexcept = default;
    18.  
    19. };
    20.  
    21. int main() {
    22. auto instance = MySingleClassInstance::GetInstance();
    23. return 0;
    24. }