mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-28 09:31:38 +00:00
improve examples in manual (#16497)
* improve examples in manual * Update doc/manual.rst Co-authored-by: Clyybber <darkmine956@gmail.com> * Update tests/cpp/ttemplatetype.nim Co-authored-by: Clyybber <darkmine956@gmail.com> Co-authored-by: Clyybber <darkmine956@gmail.com>
This commit is contained in:
@@ -7062,8 +7062,10 @@ one can import C++'s templates rather easily without the need for a pattern
|
||||
language for object types:
|
||||
|
||||
.. code-block:: nim
|
||||
:test: "nim cpp $1"
|
||||
|
||||
type
|
||||
StdMap {.importcpp: "std::map", header: "<map>".} [K, V] = object
|
||||
StdMap[K, V] {.importcpp: "std::map", header: "<map>".} = object
|
||||
proc `[]=`[K, V](this: var StdMap[K, V]; key: K; val: V) {.
|
||||
importcpp: "#[#] = #", header: "<map>".}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ discard """
|
||||
"""
|
||||
|
||||
type
|
||||
Map {.importcpp: "std::map", header: "<map>".} [T,U] = object
|
||||
Map[T,U] {.importcpp: "std::map", header: "<map>".} = object
|
||||
|
||||
proc cInitMap(T: typedesc, U: typedesc): Map[T,U] {.importcpp: "std::map<'*1,'*2>()", nodecl.}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user