make_shared.protected.fail.cpp 793 B

123456789101112131415161718192021222324252627282930
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // <memory>
  9. // shared_ptr
  10. // template<class T, class... Args> shared_ptr<T> make_shared(Args&&... args);
  11. #include <memory>
  12. #include <cassert>
  13. #include "test_macros.h"
  14. struct S {
  15. protected:
  16. S () {}; // ctor is protected
  17. };
  18. int main(int, char**)
  19. {
  20. std::shared_ptr<S> p = std::make_shared<S>(); // expected-error-re@memory:* {{static_assert failed{{.*}} "Can't construct object in make_shared"}}
  21. return 0;
  22. }