cppstl/std_smartptrs

Types

CppSharedPtr[T] {.importcpp: "std::shared_ptr", bycopy.} = object
CppUniquePtr[T] {.importcpp: "std::unique_ptr", header: "<memory>", bycopy.} = object

Procs

func `$`[T](p: CppSharedPtr[T]): string
proc `$`[T](p: CppUniquePtr[T]): string
proc `=copy`[T](dst: var CppUniquePtr[T]; src: CppUniquePtr[T]) {.
    error: "A unique ptr cannot be copied", header: "<memory>", ...raises: [],
    tags: [].}
proc `=copy`[T](p: var CppSharedPtr[T]; o: CppSharedPtr[T]) {.noInit,
    importcpp: "# = #", header: "<memory>", ...raises: [], tags: [].}
proc `=sink`[T](dst: var CppSharedPtr[T]; src: CppSharedPtr[T]) {.
    importcpp: "# = std::move(#)", header: "<memory>", ...raises: [], tags: [].}
proc `=sink`[T](dst: var CppUniquePtr[T]; src: CppUniquePtr[T]) {.
    importcpp: "# = std::move(#)", header: "<memory>", ...raises: [], tags: [].}
func deref[T](p: CppUniquePtr[T] or CppSharedPtr[T]): var T {.noInit,
    importcpp: "(* #)", header: "<memory>", ...raises: [], tags: [].}
func get[T](p: CppUniquePtr[T] or CppSharedPtr[T]): ptr T {.noInit,
    importcpp: "(#.get())", header: "<memory>", ...raises: [], tags: [].}
func makeShared(T: typedesc): CppSharedPtr[T] {.
    importcpp: "std::make_shared<\'*0>()", header: "<memory>", ...raises: [],
    tags: [].}
func makeShared[T](p: CppSharedPtr[T]): CppSharedPtr[T] {.
    importcpp: "std::make_shared<\'*0>(#)", header: "<memory>", ...raises: [],
    tags: [].}
func makeUnique(T: typedesc): CppUniquePtr[T] {.
    importcpp: "std::make_unique<\'*0>()", header: "<memory>", ...raises: [],
    tags: [].}
proc newCppSharedPtr[T](p: ptr T): CppSharedPtr[T] {.constructor,
    importcpp: "std::shared_ptr<\'*0>(#)", header: "<memory>", ...raises: [],
    tags: [].}

Macros

macro `.()`[T](p: CppUniquePtr[T] or CppSharedPtr[T]; fieldOrFunc: untyped;
               args: varargs[untyped]): untyped
macro `.=`[T](p: CppUniquePtr[T] or CppSharedPtr[T]; fieldOrFunc: untyped;
              args: untyped): untyped
macro `.`[T](p: CppUniquePtr[T] or CppSharedPtr[T]; fieldOrFunc: untyped): untyped