| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- //
- // pointer_fwd.hpp
- // memory
- //
- // Created by Sam Jaffe on 8/8/16.
- //
- #pragma once
- #include <stdexcept>
- template <typename> class not_null;
- template <typename> class maybe_null;
- template <typename> class owner;
- template <typename> class const_propogating_ptr;
- template <typename> class const_ptr;
- class unchecked_pointer_exception;
- class null_pointer_exception : public std::invalid_argument {
- using std::invalid_argument::invalid_argument;
- };
- namespace detail {
- template <typename P> using is_nt_cc = std::is_nothrow_copy_constructible<P>;
- template <typename P> using is_nt_ca = std::is_nothrow_copy_assignable<P>;
- template <typename P> using is_nt_mc = std::is_nothrow_move_constructible<P>;
- template <typename P> using is_nt_ma = std::is_nothrow_move_assignable<P>;
- template <typename P, typename Y>
- using is_nt_c = std::is_nothrow_constructible<P, Y>;
- template <typename P, typename Y>
- using is_nt_a = std::is_nothrow_assignable<P, Y>;
- template <typename P, typename = void> struct get_ptr {
- decltype(std::declval<P>().get()) get(P const & ptr) const {
- return std::addressof(*ptr);
- }
- };
- template <typename T> struct get_ptr<std::weak_ptr<T>> {
- void get(std::weak_ptr<T> const & ptr) throw();
- };
- template <typename T> struct get_ptr<T *> {
- T * get(T * ptr) const { return ptr; }
- };
- template <typename P>
- struct get_ptr<P, typename std::enable_if<!std::is_void<decltype(
- std::declval<P>().get())>::value>::type> {
- decltype(std::declval<P>().get()) get(P const & ptr) const {
- return ptr.get();
- }
- };
- }
|