netgen-mesher 6.2.2506.post35.dev0__cp314-cp314-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. netgen/NgOCC.py +7 -0
  2. netgen/__init__.py +114 -0
  3. netgen/__init__.pyi +22 -0
  4. netgen/__main__.py +53 -0
  5. netgen/cmake/NetgenConfig.cmake +79 -0
  6. netgen/cmake/netgen-targets-release.cmake +69 -0
  7. netgen/cmake/netgen-targets.cmake +146 -0
  8. netgen/config/__init__.py +1 -0
  9. netgen/config/__init__.pyi +52 -0
  10. netgen/config/__main__.py +4 -0
  11. netgen/config/config.py +68 -0
  12. netgen/config/config.pyi +54 -0
  13. netgen/csg.py +25 -0
  14. netgen/geom2d.py +178 -0
  15. netgen/gui.py +82 -0
  16. netgen/include/core/archive.hpp +1256 -0
  17. netgen/include/core/array.hpp +1760 -0
  18. netgen/include/core/autodiff.hpp +1131 -0
  19. netgen/include/core/autodiffdiff.hpp +733 -0
  20. netgen/include/core/bitarray.hpp +240 -0
  21. netgen/include/core/concurrentqueue.h +3619 -0
  22. netgen/include/core/exception.hpp +145 -0
  23. netgen/include/core/flags.hpp +199 -0
  24. netgen/include/core/hashtable.hpp +1281 -0
  25. netgen/include/core/localheap.hpp +318 -0
  26. netgen/include/core/logging.hpp +117 -0
  27. netgen/include/core/memtracer.hpp +221 -0
  28. netgen/include/core/mpi4py_pycapi.h +245 -0
  29. netgen/include/core/mpi_wrapper.hpp +643 -0
  30. netgen/include/core/ng_mpi.hpp +94 -0
  31. netgen/include/core/ng_mpi_generated_declarations.hpp +155 -0
  32. netgen/include/core/ng_mpi_native.hpp +25 -0
  33. netgen/include/core/ngcore.hpp +32 -0
  34. netgen/include/core/ngcore_api.hpp +152 -0
  35. netgen/include/core/ngstream.hpp +115 -0
  36. netgen/include/core/paje_trace.hpp +279 -0
  37. netgen/include/core/profiler.hpp +382 -0
  38. netgen/include/core/python_ngcore.hpp +457 -0
  39. netgen/include/core/ranges.hpp +109 -0
  40. netgen/include/core/register_archive.hpp +100 -0
  41. netgen/include/core/signal.hpp +82 -0
  42. netgen/include/core/simd.hpp +160 -0
  43. netgen/include/core/simd_arm64.hpp +407 -0
  44. netgen/include/core/simd_avx.hpp +394 -0
  45. netgen/include/core/simd_avx512.hpp +285 -0
  46. netgen/include/core/simd_generic.hpp +1053 -0
  47. netgen/include/core/simd_math.hpp +178 -0
  48. netgen/include/core/simd_sse.hpp +289 -0
  49. netgen/include/core/statushandler.hpp +37 -0
  50. netgen/include/core/symboltable.hpp +153 -0
  51. netgen/include/core/table.hpp +810 -0
  52. netgen/include/core/taskmanager.hpp +1161 -0
  53. netgen/include/core/type_traits.hpp +65 -0
  54. netgen/include/core/utils.hpp +385 -0
  55. netgen/include/core/version.hpp +102 -0
  56. netgen/include/core/xbool.hpp +47 -0
  57. netgen/include/csg/algprim.hpp +563 -0
  58. netgen/include/csg/brick.hpp +150 -0
  59. netgen/include/csg/csg.hpp +43 -0
  60. netgen/include/csg/csgeom.hpp +389 -0
  61. netgen/include/csg/csgparser.hpp +101 -0
  62. netgen/include/csg/curve2d.hpp +67 -0
  63. netgen/include/csg/edgeflw.hpp +112 -0
  64. netgen/include/csg/explicitcurve2d.hpp +113 -0
  65. netgen/include/csg/extrusion.hpp +185 -0
  66. netgen/include/csg/gencyl.hpp +70 -0
  67. netgen/include/csg/geoml.hpp +16 -0
  68. netgen/include/csg/identify.hpp +213 -0
  69. netgen/include/csg/manifold.hpp +29 -0
  70. netgen/include/csg/meshsurf.hpp +46 -0
  71. netgen/include/csg/polyhedra.hpp +121 -0
  72. netgen/include/csg/revolution.hpp +180 -0
  73. netgen/include/csg/singularref.hpp +84 -0
  74. netgen/include/csg/solid.hpp +295 -0
  75. netgen/include/csg/specpoin.hpp +194 -0
  76. netgen/include/csg/spline3d.hpp +99 -0
  77. netgen/include/csg/splinesurface.hpp +85 -0
  78. netgen/include/csg/surface.hpp +394 -0
  79. netgen/include/csg/triapprox.hpp +63 -0
  80. netgen/include/csg/vscsg.hpp +34 -0
  81. netgen/include/general/autodiff.hpp +356 -0
  82. netgen/include/general/autoptr.hpp +39 -0
  83. netgen/include/general/gzstream.h +121 -0
  84. netgen/include/general/hashtabl.hpp +1692 -0
  85. netgen/include/general/myadt.hpp +48 -0
  86. netgen/include/general/mystring.hpp +226 -0
  87. netgen/include/general/netgenout.hpp +205 -0
  88. netgen/include/general/ngarray.hpp +797 -0
  89. netgen/include/general/ngbitarray.hpp +149 -0
  90. netgen/include/general/ngpython.hpp +74 -0
  91. netgen/include/general/optmem.hpp +44 -0
  92. netgen/include/general/parthreads.hpp +138 -0
  93. netgen/include/general/seti.hpp +50 -0
  94. netgen/include/general/sort.hpp +47 -0
  95. netgen/include/general/spbita2d.hpp +59 -0
  96. netgen/include/general/stack.hpp +114 -0
  97. netgen/include/general/table.hpp +280 -0
  98. netgen/include/general/template.hpp +509 -0
  99. netgen/include/geom2d/csg2d.hpp +750 -0
  100. netgen/include/geom2d/geometry2d.hpp +280 -0
  101. netgen/include/geom2d/spline2d.hpp +234 -0
  102. netgen/include/geom2d/vsgeom2d.hpp +28 -0
  103. netgen/include/gprim/adtree.hpp +1392 -0
  104. netgen/include/gprim/geom2d.hpp +858 -0
  105. netgen/include/gprim/geom3d.hpp +749 -0
  106. netgen/include/gprim/geomfuncs.hpp +212 -0
  107. netgen/include/gprim/geomobjects.hpp +544 -0
  108. netgen/include/gprim/geomops.hpp +404 -0
  109. netgen/include/gprim/geomtest3d.hpp +101 -0
  110. netgen/include/gprim/gprim.hpp +33 -0
  111. netgen/include/gprim/spline.hpp +778 -0
  112. netgen/include/gprim/splinegeometry.hpp +73 -0
  113. netgen/include/gprim/transform3d.hpp +216 -0
  114. netgen/include/include/acisgeom.hpp +3 -0
  115. netgen/include/include/csg.hpp +1 -0
  116. netgen/include/include/geometry2d.hpp +1 -0
  117. netgen/include/include/gprim.hpp +1 -0
  118. netgen/include/include/incopengl.hpp +62 -0
  119. netgen/include/include/inctcl.hpp +13 -0
  120. netgen/include/include/incvis.hpp +6 -0
  121. netgen/include/include/linalg.hpp +1 -0
  122. netgen/include/include/meshing.hpp +1 -0
  123. netgen/include/include/myadt.hpp +1 -0
  124. netgen/include/include/mydefs.hpp +70 -0
  125. netgen/include/include/mystdlib.h +59 -0
  126. netgen/include/include/netgen_config.hpp +27 -0
  127. netgen/include/include/netgen_version.hpp +9 -0
  128. netgen/include/include/nginterface_v2_impl.hpp +395 -0
  129. netgen/include/include/ngsimd.hpp +1 -0
  130. netgen/include/include/occgeom.hpp +1 -0
  131. netgen/include/include/opti.hpp +1 -0
  132. netgen/include/include/parallel.hpp +1 -0
  133. netgen/include/include/stlgeom.hpp +1 -0
  134. netgen/include/include/visual.hpp +1 -0
  135. netgen/include/interface/rw_medit.hpp +11 -0
  136. netgen/include/interface/writeuser.hpp +80 -0
  137. netgen/include/linalg/densemat.hpp +414 -0
  138. netgen/include/linalg/linalg.hpp +29 -0
  139. netgen/include/linalg/opti.hpp +142 -0
  140. netgen/include/linalg/polynomial.hpp +47 -0
  141. netgen/include/linalg/vector.hpp +217 -0
  142. netgen/include/meshing/adfront2.hpp +274 -0
  143. netgen/include/meshing/adfront3.hpp +332 -0
  144. netgen/include/meshing/basegeom.hpp +370 -0
  145. netgen/include/meshing/bcfunctions.hpp +53 -0
  146. netgen/include/meshing/bisect.hpp +72 -0
  147. netgen/include/meshing/boundarylayer.hpp +113 -0
  148. netgen/include/meshing/classifyhpel.hpp +1984 -0
  149. netgen/include/meshing/clusters.hpp +46 -0
  150. netgen/include/meshing/curvedelems.hpp +274 -0
  151. netgen/include/meshing/delaunay2d.hpp +73 -0
  152. netgen/include/meshing/fieldlines.hpp +103 -0
  153. netgen/include/meshing/findip.hpp +198 -0
  154. netgen/include/meshing/findip2.hpp +103 -0
  155. netgen/include/meshing/geomsearch.hpp +69 -0
  156. netgen/include/meshing/global.hpp +54 -0
  157. netgen/include/meshing/hpref_hex.hpp +330 -0
  158. netgen/include/meshing/hpref_prism.hpp +3405 -0
  159. netgen/include/meshing/hpref_pyramid.hpp +154 -0
  160. netgen/include/meshing/hpref_quad.hpp +2082 -0
  161. netgen/include/meshing/hpref_segm.hpp +122 -0
  162. netgen/include/meshing/hpref_tet.hpp +4230 -0
  163. netgen/include/meshing/hpref_trig.hpp +848 -0
  164. netgen/include/meshing/hprefinement.hpp +366 -0
  165. netgen/include/meshing/improve2.hpp +178 -0
  166. netgen/include/meshing/improve3.hpp +151 -0
  167. netgen/include/meshing/localh.hpp +223 -0
  168. netgen/include/meshing/meshclass.hpp +1076 -0
  169. netgen/include/meshing/meshfunc.hpp +47 -0
  170. netgen/include/meshing/meshing.hpp +63 -0
  171. netgen/include/meshing/meshing2.hpp +163 -0
  172. netgen/include/meshing/meshing3.hpp +123 -0
  173. netgen/include/meshing/meshtool.hpp +90 -0
  174. netgen/include/meshing/meshtype.hpp +1930 -0
  175. netgen/include/meshing/msghandler.hpp +62 -0
  176. netgen/include/meshing/paralleltop.hpp +172 -0
  177. netgen/include/meshing/python_mesh.hpp +206 -0
  178. netgen/include/meshing/ruler2.hpp +172 -0
  179. netgen/include/meshing/ruler3.hpp +211 -0
  180. netgen/include/meshing/soldata.hpp +141 -0
  181. netgen/include/meshing/specials.hpp +17 -0
  182. netgen/include/meshing/surfacegeom.hpp +73 -0
  183. netgen/include/meshing/topology.hpp +1003 -0
  184. netgen/include/meshing/validate.hpp +21 -0
  185. netgen/include/meshing/visual_interface.hpp +71 -0
  186. netgen/include/mydefs.hpp +70 -0
  187. netgen/include/nginterface.h +474 -0
  188. netgen/include/nginterface_v2.hpp +406 -0
  189. netgen/include/nglib.h +697 -0
  190. netgen/include/nglib_occ.h +50 -0
  191. netgen/include/occ/occ_edge.hpp +47 -0
  192. netgen/include/occ/occ_face.hpp +52 -0
  193. netgen/include/occ/occ_solid.hpp +23 -0
  194. netgen/include/occ/occ_utils.hpp +376 -0
  195. netgen/include/occ/occ_vertex.hpp +30 -0
  196. netgen/include/occ/occgeom.hpp +659 -0
  197. netgen/include/occ/occmeshsurf.hpp +168 -0
  198. netgen/include/occ/vsocc.hpp +33 -0
  199. netgen/include/pybind11/LICENSE +29 -0
  200. netgen/include/pybind11/attr.h +722 -0
  201. netgen/include/pybind11/buffer_info.h +208 -0
  202. netgen/include/pybind11/cast.h +2361 -0
  203. netgen/include/pybind11/chrono.h +228 -0
  204. netgen/include/pybind11/common.h +2 -0
  205. netgen/include/pybind11/complex.h +74 -0
  206. netgen/include/pybind11/conduit/README.txt +15 -0
  207. netgen/include/pybind11/conduit/pybind11_conduit_v1.h +116 -0
  208. netgen/include/pybind11/conduit/pybind11_platform_abi_id.h +87 -0
  209. netgen/include/pybind11/conduit/wrap_include_python_h.h +72 -0
  210. netgen/include/pybind11/critical_section.h +56 -0
  211. netgen/include/pybind11/detail/class.h +823 -0
  212. netgen/include/pybind11/detail/common.h +1348 -0
  213. netgen/include/pybind11/detail/cpp_conduit.h +75 -0
  214. netgen/include/pybind11/detail/descr.h +226 -0
  215. netgen/include/pybind11/detail/dynamic_raw_ptr_cast_if_possible.h +39 -0
  216. netgen/include/pybind11/detail/exception_translation.h +71 -0
  217. netgen/include/pybind11/detail/function_record_pyobject.h +191 -0
  218. netgen/include/pybind11/detail/init.h +538 -0
  219. netgen/include/pybind11/detail/internals.h +799 -0
  220. netgen/include/pybind11/detail/native_enum_data.h +209 -0
  221. netgen/include/pybind11/detail/pybind11_namespace_macros.h +82 -0
  222. netgen/include/pybind11/detail/struct_smart_holder.h +378 -0
  223. netgen/include/pybind11/detail/type_caster_base.h +1591 -0
  224. netgen/include/pybind11/detail/typeid.h +65 -0
  225. netgen/include/pybind11/detail/using_smart_holder.h +22 -0
  226. netgen/include/pybind11/detail/value_and_holder.h +90 -0
  227. netgen/include/pybind11/eigen/common.h +9 -0
  228. netgen/include/pybind11/eigen/matrix.h +723 -0
  229. netgen/include/pybind11/eigen/tensor.h +521 -0
  230. netgen/include/pybind11/eigen.h +12 -0
  231. netgen/include/pybind11/embed.h +320 -0
  232. netgen/include/pybind11/eval.h +161 -0
  233. netgen/include/pybind11/functional.h +147 -0
  234. netgen/include/pybind11/gil.h +199 -0
  235. netgen/include/pybind11/gil_safe_call_once.h +102 -0
  236. netgen/include/pybind11/gil_simple.h +37 -0
  237. netgen/include/pybind11/iostream.h +265 -0
  238. netgen/include/pybind11/native_enum.h +67 -0
  239. netgen/include/pybind11/numpy.h +2312 -0
  240. netgen/include/pybind11/operators.h +202 -0
  241. netgen/include/pybind11/options.h +92 -0
  242. netgen/include/pybind11/pybind11.h +3645 -0
  243. netgen/include/pybind11/pytypes.h +2680 -0
  244. netgen/include/pybind11/stl/filesystem.h +114 -0
  245. netgen/include/pybind11/stl.h +666 -0
  246. netgen/include/pybind11/stl_bind.h +858 -0
  247. netgen/include/pybind11/subinterpreter.h +299 -0
  248. netgen/include/pybind11/trampoline_self_life_support.h +65 -0
  249. netgen/include/pybind11/type_caster_pyobject_ptr.h +61 -0
  250. netgen/include/pybind11/typing.h +298 -0
  251. netgen/include/pybind11/warnings.h +75 -0
  252. netgen/include/stlgeom/meshstlsurface.hpp +67 -0
  253. netgen/include/stlgeom/stlgeom.hpp +491 -0
  254. netgen/include/stlgeom/stlline.hpp +193 -0
  255. netgen/include/stlgeom/stltool.hpp +331 -0
  256. netgen/include/stlgeom/stltopology.hpp +419 -0
  257. netgen/include/stlgeom/vsstl.hpp +58 -0
  258. netgen/include/visualization/meshdoc.hpp +42 -0
  259. netgen/include/visualization/mvdraw.hpp +325 -0
  260. netgen/include/visualization/vispar.hpp +128 -0
  261. netgen/include/visualization/visual.hpp +28 -0
  262. netgen/include/visualization/visual_api.hpp +10 -0
  263. netgen/include/visualization/vssolution.hpp +399 -0
  264. netgen/lib/libnggui.lib +0 -0
  265. netgen/lib/ngcore.lib +0 -0
  266. netgen/lib/nglib.lib +0 -0
  267. netgen/lib/togl.lib +0 -0
  268. netgen/libnggui.dll +0 -0
  269. netgen/libngguipy.lib +0 -0
  270. netgen/libngguipy.pyd +0 -0
  271. netgen/libngpy/_NgOCC.pyi +1545 -0
  272. netgen/libngpy/__init__.pyi +7 -0
  273. netgen/libngpy/_csg.pyi +259 -0
  274. netgen/libngpy/_geom2d.pyi +323 -0
  275. netgen/libngpy/_meshing.pyi +1111 -0
  276. netgen/libngpy/_stl.pyi +131 -0
  277. netgen/libngpy.lib +0 -0
  278. netgen/libngpy.pyd +0 -0
  279. netgen/meshing.py +65 -0
  280. netgen/ngcore.dll +0 -0
  281. netgen/nglib.dll +0 -0
  282. netgen/occ.py +52 -0
  283. netgen/read_gmsh.py +259 -0
  284. netgen/read_meshio.py +22 -0
  285. netgen/stl.py +2 -0
  286. netgen/togl.dll +0 -0
  287. netgen/version.py +2 -0
  288. netgen/webgui.py +529 -0
  289. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/boundarycondition.geo +16 -0
  290. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/boxcyl.geo +32 -0
  291. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/circle_on_cube.geo +27 -0
  292. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cone.geo +13 -0
  293. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cube.geo +16 -0
  294. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubeandring.geo +55 -0
  295. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubeandspheres.geo +21 -0
  296. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubemcyl.geo +18 -0
  297. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cubemsphere.geo +19 -0
  298. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cylinder.geo +12 -0
  299. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/cylsphere.geo +12 -0
  300. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/doc/ng4.pdf +0 -0
  301. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/ellipsoid.geo +8 -0
  302. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/ellipticcyl.geo +10 -0
  303. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/extrusion.geo +99 -0
  304. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/fichera.geo +24 -0
  305. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/frame.step +11683 -0
  306. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/hinge.stl +8486 -0
  307. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/lshape3d.geo +26 -0
  308. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/manyholes.geo +26 -0
  309. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/manyholes2.geo +26 -0
  310. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/matrix.geo +27 -0
  311. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/ortho.geo +11 -0
  312. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/part1.stl +2662 -0
  313. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/period.geo +33 -0
  314. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/py_tutorials/exportNeutral.py +26 -0
  315. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/py_tutorials/mesh.py +19 -0
  316. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/py_tutorials/shaft.geo +65 -0
  317. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/revolution.geo +18 -0
  318. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/screw.step +1694 -0
  319. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/sculpture.geo +13 -0
  320. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/shaft.geo +65 -0
  321. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/shell.geo +10 -0
  322. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/sphere.geo +8 -0
  323. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/sphereincube.geo +17 -0
  324. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/square.in2d +35 -0
  325. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/squarecircle.in2d +48 -0
  326. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/squarehole.in2d +47 -0
  327. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/torus.geo +8 -0
  328. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/trafo.geo +57 -0
  329. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/twobricks.geo +15 -0
  330. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/twocubes.geo +18 -0
  331. netgen_mesher-6.2.2506.post35.dev0.data/data/share/netgen/twocyl.geo +16 -0
  332. netgen_mesher-6.2.2506.post35.dev0.dist-info/METADATA +15 -0
  333. netgen_mesher-6.2.2506.post35.dev0.dist-info/RECORD +340 -0
  334. netgen_mesher-6.2.2506.post35.dev0.dist-info/WHEEL +5 -0
  335. netgen_mesher-6.2.2506.post35.dev0.dist-info/entry_points.txt +2 -0
  336. netgen_mesher-6.2.2506.post35.dev0.dist-info/licenses/AUTHORS +1 -0
  337. netgen_mesher-6.2.2506.post35.dev0.dist-info/licenses/LICENSE +504 -0
  338. netgen_mesher-6.2.2506.post35.dev0.dist-info/top_level.txt +2 -0
  339. pyngcore/__init__.py +1 -0
  340. pyngcore/pyngcore.cp314-win_amd64.pyd +0 -0
@@ -0,0 +1,538 @@
1
+ /*
2
+ pybind11/detail/init.h: init factory function implementation and support code.
3
+
4
+ Copyright (c) 2017 Jason Rhinelander <jason@imaginary.ca>
5
+
6
+ All rights reserved. Use of this source code is governed by a
7
+ BSD-style license that can be found in the LICENSE file.
8
+ */
9
+
10
+ #pragma once
11
+
12
+ #include "class.h"
13
+ #include "using_smart_holder.h"
14
+
15
+ PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
16
+
17
+ PYBIND11_WARNING_DISABLE_MSVC(4127)
18
+
19
+ PYBIND11_NAMESPACE_BEGIN(detail)
20
+
21
+ template <>
22
+ class type_caster<value_and_holder> {
23
+ public:
24
+ bool load(handle h, bool) {
25
+ value = reinterpret_cast<value_and_holder *>(h.ptr());
26
+ return true;
27
+ }
28
+
29
+ template <typename>
30
+ using cast_op_type = value_and_holder &;
31
+ explicit operator value_and_holder &() { return *value; }
32
+ static constexpr auto name = const_name<value_and_holder>();
33
+
34
+ private:
35
+ value_and_holder *value = nullptr;
36
+ };
37
+
38
+ PYBIND11_NAMESPACE_BEGIN(initimpl)
39
+
40
+ inline void no_nullptr(const void *ptr) {
41
+ if (!ptr) {
42
+ throw type_error("pybind11::init(): factory function returned nullptr");
43
+ }
44
+ }
45
+
46
+ // Implementing functions for all forms of py::init<...> and py::init(...)
47
+ template <typename Class>
48
+ using Cpp = typename Class::type;
49
+ template <typename Class>
50
+ using Alias = typename Class::type_alias;
51
+ template <typename Class>
52
+ using Holder = typename Class::holder_type;
53
+
54
+ template <typename Class>
55
+ using is_alias_constructible = std::is_constructible<Alias<Class>, Cpp<Class> &&>;
56
+
57
+ // Takes a Cpp pointer and returns true if it actually is a polymorphic Alias instance.
58
+ template <typename Class, enable_if_t<Class::has_alias, int> = 0>
59
+ bool is_alias(Cpp<Class> *ptr) {
60
+ return dynamic_cast<Alias<Class> *>(ptr) != nullptr;
61
+ }
62
+ // Failing fallback version of the above for a no-alias class (always returns false)
63
+ template <typename /*Class*/>
64
+ constexpr bool is_alias(const void *) {
65
+ return false;
66
+ }
67
+
68
+ // Constructs and returns a new object; if the given arguments don't map to a constructor, we fall
69
+ // back to brace aggregate initialization so that for aggregate initialization can be used with
70
+ // py::init, e.g. `py::init<int, int>` to initialize a `struct T { int a; int b; }`. For
71
+ // non-aggregate types, we need to use an ordinary T(...) constructor (invoking as `T{...}` usually
72
+ // works, but will not do the expected thing when `T` has an `initializer_list<T>` constructor).
73
+ template <typename Class,
74
+ typename... Args,
75
+ detail::enable_if_t<std::is_constructible<Class, Args...>::value, int> = 0>
76
+ inline Class *construct_or_initialize(Args &&...args) {
77
+ return new Class(std::forward<Args>(args)...);
78
+ }
79
+ template <typename Class,
80
+ typename... Args,
81
+ detail::enable_if_t<!std::is_constructible<Class, Args...>::value, int> = 0>
82
+ inline Class *construct_or_initialize(Args &&...args) {
83
+ return new Class{std::forward<Args>(args)...};
84
+ }
85
+
86
+ // Attempts to constructs an alias using a `Alias(Cpp &&)` constructor. This allows types with
87
+ // an alias to provide only a single Cpp factory function as long as the Alias can be
88
+ // constructed from an rvalue reference of the base Cpp type. This means that Alias classes
89
+ // can, when appropriate, simply define a `Alias(Cpp &&)` constructor rather than needing to
90
+ // inherit all the base class constructors.
91
+ template <typename Class>
92
+ void construct_alias_from_cpp(std::true_type /*is_alias_constructible*/,
93
+ value_and_holder &v_h,
94
+ Cpp<Class> &&base) {
95
+ v_h.value_ptr() = new Alias<Class>(std::move(base));
96
+ }
97
+ template <typename Class>
98
+ [[noreturn]] void construct_alias_from_cpp(std::false_type /*!is_alias_constructible*/,
99
+ value_and_holder &,
100
+ Cpp<Class> &&) {
101
+ throw type_error("pybind11::init(): unable to convert returned instance to required "
102
+ "alias class: no `Alias<Class>(Class &&)` constructor available");
103
+ }
104
+
105
+ // Error-generating fallback for factories that don't match one of the below construction
106
+ // mechanisms.
107
+ template <typename Class>
108
+ void construct(...) {
109
+ static_assert(!std::is_same<Class, Class>::value /* always false */,
110
+ "pybind11::init(): init function must return a compatible pointer, "
111
+ "holder, or value");
112
+ }
113
+
114
+ // Pointer return v1: the factory function returns a class pointer for a registered class.
115
+ // If we don't need an alias (because this class doesn't have one, or because the final type is
116
+ // inherited on the Python side) we can simply take over ownership. Otherwise we need to try to
117
+ // construct an Alias from the returned base instance.
118
+ template <typename Class>
119
+ void construct(value_and_holder &v_h, Cpp<Class> *ptr, bool need_alias) {
120
+ PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(need_alias);
121
+ no_nullptr(ptr);
122
+ if (Class::has_alias && need_alias && !is_alias<Class>(ptr)) {
123
+ // We're going to try to construct an alias by moving the cpp type. Whether or not
124
+ // that succeeds, we still need to destroy the original cpp pointer (either the
125
+ // moved away leftover, if the alias construction works, or the value itself if we
126
+ // throw an error), but we can't just call `delete ptr`: it might have a special
127
+ // deleter, or might be shared_from_this. So we construct a holder around it as if
128
+ // it was a normal instance, then steal the holder away into a local variable; thus
129
+ // the holder and destruction happens when we leave the C++ scope, and the holder
130
+ // class gets to handle the destruction however it likes.
131
+ v_h.value_ptr() = ptr;
132
+ v_h.set_instance_registered(true); // Trick to prevent init_instance from registering it
133
+ // DANGER ZONE BEGIN: exceptions will leave v_h in an invalid state.
134
+ v_h.type->init_instance(v_h.inst, nullptr); // Set up the holder
135
+ Holder<Class> temp_holder(std::move(v_h.holder<Holder<Class>>())); // Steal the holder
136
+ v_h.type->dealloc(v_h); // Destroys the moved-out holder remains, resets value ptr to null
137
+ v_h.set_instance_registered(false);
138
+ // DANGER ZONE END.
139
+
140
+ construct_alias_from_cpp<Class>(is_alias_constructible<Class>{}, v_h, std::move(*ptr));
141
+ } else {
142
+ // Otherwise the type isn't inherited, so we don't need an Alias
143
+ v_h.value_ptr() = ptr;
144
+ }
145
+ }
146
+
147
+ // Pointer return v2: a factory that always returns an alias instance ptr. We simply take over
148
+ // ownership of the pointer.
149
+ template <typename Class, enable_if_t<Class::has_alias, int> = 0>
150
+ void construct(value_and_holder &v_h, Alias<Class> *alias_ptr, bool) {
151
+ no_nullptr(alias_ptr);
152
+ v_h.value_ptr() = static_cast<Cpp<Class> *>(alias_ptr);
153
+ }
154
+
155
+ // Holder return: copy its pointer, and move or copy the returned holder into the new instance's
156
+ // holder. This also handles types like std::shared_ptr<T> and std::unique_ptr<T> where T is a
157
+ // derived type (through those holder's implicit conversion from derived class holder
158
+ // constructors).
159
+ template <typename Class, detail::enable_if_t<!is_smart_holder<Holder<Class>>::value, int> = 0>
160
+ void construct(value_and_holder &v_h, Holder<Class> holder, bool need_alias) {
161
+ PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(need_alias);
162
+ auto *ptr = holder_helper<Holder<Class>>::get(holder);
163
+ no_nullptr(ptr);
164
+ // If we need an alias, check that the held pointer is actually an alias instance
165
+ if (Class::has_alias && need_alias && !is_alias<Class>(ptr)) {
166
+ throw type_error("pybind11::init(): construction failed: returned holder-wrapped instance "
167
+ "is not an alias instance");
168
+ }
169
+
170
+ // Cast away constness to store in void* storage.
171
+ // The value_and_holder storage is fundamentally untyped (void**), so we lose
172
+ // const-correctness here by design. The const qualifier will be restored
173
+ // when the pointer is later retrieved and cast back to the original type.
174
+ // This explicit const_cast makes the const-removal clearly visible.
175
+ v_h.value_ptr() = const_cast<void *>(static_cast<const void *>(ptr));
176
+ v_h.type->init_instance(v_h.inst, &holder);
177
+ }
178
+
179
+ // return-by-value version 1: returning a cpp class by value. If the class has an alias and an
180
+ // alias is required the alias must have an `Alias(Cpp &&)` constructor so that we can construct
181
+ // the alias from the base when needed (i.e. because of Python-side inheritance). When we don't
182
+ // need it, we simply move-construct the cpp value into a new instance.
183
+ template <typename Class>
184
+ void construct(value_and_holder &v_h, Cpp<Class> &&result, bool need_alias) {
185
+ PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(need_alias);
186
+ static_assert(is_move_constructible<Cpp<Class>>::value,
187
+ "pybind11::init() return-by-value factory function requires a movable class");
188
+ if (Class::has_alias && need_alias) {
189
+ construct_alias_from_cpp<Class>(is_alias_constructible<Class>{}, v_h, std::move(result));
190
+ } else {
191
+ v_h.value_ptr() = new Cpp<Class>(std::move(result));
192
+ }
193
+ }
194
+
195
+ // return-by-value version 2: returning a value of the alias type itself. We move-construct an
196
+ // Alias instance (even if no the python-side inheritance is involved). The is intended for
197
+ // cases where Alias initialization is always desired.
198
+ template <typename Class>
199
+ void construct(value_and_holder &v_h, Alias<Class> &&result, bool) {
200
+ static_assert(
201
+ is_move_constructible<Alias<Class>>::value,
202
+ "pybind11::init() return-by-alias-value factory function requires a movable alias class");
203
+ v_h.value_ptr() = new Alias<Class>(std::move(result));
204
+ }
205
+
206
+ template <typename T, typename D>
207
+ smart_holder init_smart_holder_from_unique_ptr(std::unique_ptr<T, D> &&unq_ptr,
208
+ bool void_cast_raw_ptr) {
209
+ void *void_ptr = void_cast_raw_ptr ? static_cast<void *>(unq_ptr.get()) : nullptr;
210
+ return smart_holder::from_unique_ptr(std::move(unq_ptr), void_ptr);
211
+ }
212
+
213
+ template <typename Class,
214
+ typename D = std::default_delete<Cpp<Class>>,
215
+ detail::enable_if_t<is_smart_holder<Holder<Class>>::value, int> = 0>
216
+ void construct(value_and_holder &v_h, std::unique_ptr<Cpp<Class>, D> &&unq_ptr, bool need_alias) {
217
+ PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(need_alias);
218
+ auto *ptr = unq_ptr.get();
219
+ no_nullptr(ptr);
220
+ if (Class::has_alias && need_alias && !is_alias<Class>(ptr)) {
221
+ throw type_error("pybind11::init(): construction failed: returned std::unique_ptr pointee "
222
+ "is not an alias instance");
223
+ }
224
+ // Here and below: if the new object is a trampoline, the shared_from_this mechanism needs
225
+ // to be prevented from accessing the smart_holder vptr, because it does not keep the
226
+ // trampoline Python object alive. For types that don't inherit from enable_shared_from_this
227
+ // it does not matter if void_cast_raw_ptr is true or false, therefore it's not necessary
228
+ // to also inspect the type.
229
+ auto smhldr = init_smart_holder_from_unique_ptr(
230
+ std::move(unq_ptr), /*void_cast_raw_ptr*/ Class::has_alias && is_alias<Class>(ptr));
231
+ v_h.value_ptr() = ptr;
232
+ v_h.type->init_instance(v_h.inst, &smhldr);
233
+ }
234
+
235
+ template <typename Class,
236
+ typename D = std::default_delete<Alias<Class>>,
237
+ detail::enable_if_t<is_smart_holder<Holder<Class>>::value, int> = 0>
238
+ void construct(value_and_holder &v_h,
239
+ std::unique_ptr<Alias<Class>, D> &&unq_ptr,
240
+ bool /*need_alias*/) {
241
+ auto *ptr = unq_ptr.get();
242
+ no_nullptr(ptr);
243
+ auto smhldr
244
+ = init_smart_holder_from_unique_ptr(std::move(unq_ptr), /*void_cast_raw_ptr*/ true);
245
+ v_h.value_ptr() = ptr;
246
+ v_h.type->init_instance(v_h.inst, &smhldr);
247
+ }
248
+
249
+ template <typename PtrType, typename Class>
250
+ void construct_from_shared_ptr(value_and_holder &v_h,
251
+ std::shared_ptr<PtrType> &&shd_ptr,
252
+ bool need_alias) {
253
+ static_assert(std::is_same<PtrType, Cpp<Class>>::value
254
+ || std::is_same<PtrType, const Cpp<Class>>::value,
255
+ "Expected (const) Cpp<Class> as shared_ptr pointee");
256
+ auto *ptr = shd_ptr.get();
257
+ no_nullptr(ptr);
258
+ if (Class::has_alias && need_alias && !is_alias<Class>(ptr)) {
259
+ throw type_error("pybind11::init(): construction failed: returned std::shared_ptr pointee "
260
+ "is not an alias instance");
261
+ }
262
+ // Cast to non-const if needed, consistent with internal design
263
+ auto smhldr
264
+ = smart_holder::from_shared_ptr(std::const_pointer_cast<Cpp<Class>>(std::move(shd_ptr)));
265
+ v_h.value_ptr() = const_cast<Cpp<Class> *>(ptr);
266
+ v_h.type->init_instance(v_h.inst, &smhldr);
267
+ }
268
+
269
+ template <typename Class, detail::enable_if_t<is_smart_holder<Holder<Class>>::value, int> = 0>
270
+ void construct(value_and_holder &v_h, std::shared_ptr<Cpp<Class>> &&shd_ptr, bool need_alias) {
271
+ construct_from_shared_ptr<Cpp<Class>, Class>(v_h, std::move(shd_ptr), need_alias);
272
+ }
273
+
274
+ template <typename Class, detail::enable_if_t<is_smart_holder<Holder<Class>>::value, int> = 0>
275
+ void construct(value_and_holder &v_h,
276
+ std::shared_ptr<const Cpp<Class>> &&shd_ptr,
277
+ bool need_alias) {
278
+ construct_from_shared_ptr<const Cpp<Class>, Class>(v_h, std::move(shd_ptr), need_alias);
279
+ }
280
+
281
+ template <typename Class, detail::enable_if_t<is_smart_holder<Holder<Class>>::value, int> = 0>
282
+ void construct(value_and_holder &v_h,
283
+ std::shared_ptr<Alias<Class>> &&shd_ptr,
284
+ bool /*need_alias*/) {
285
+ auto *ptr = shd_ptr.get();
286
+ no_nullptr(ptr);
287
+ auto smhldr = smart_holder::from_shared_ptr(shd_ptr);
288
+ v_h.value_ptr() = ptr;
289
+ v_h.type->init_instance(v_h.inst, &smhldr);
290
+ }
291
+
292
+ // Implementing class for py::init<...>()
293
+ template <typename... Args>
294
+ struct constructor {
295
+ template <typename Class, typename... Extra, enable_if_t<!Class::has_alias, int> = 0>
296
+ static void execute(Class &cl, const Extra &...extra) {
297
+ cl.def(
298
+ "__init__",
299
+ [](value_and_holder &v_h,
300
+ Args... args) { // NOLINT(performance-unnecessary-value-param)
301
+ v_h.value_ptr() = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
302
+ },
303
+ is_new_style_constructor(),
304
+ extra...);
305
+ }
306
+
307
+ template <
308
+ typename Class,
309
+ typename... Extra,
310
+ enable_if_t<Class::has_alias && std::is_constructible<Cpp<Class>, Args...>::value, int>
311
+ = 0>
312
+ static void execute(Class &cl, const Extra &...extra) {
313
+ cl.def(
314
+ "__init__",
315
+ [](value_and_holder &v_h, Args... args) {
316
+ if (Py_TYPE(v_h.inst) == v_h.type->type) {
317
+ v_h.value_ptr()
318
+ = construct_or_initialize<Cpp<Class>>(std::forward<Args>(args)...);
319
+ } else {
320
+ v_h.value_ptr()
321
+ = construct_or_initialize<Alias<Class>>(std::forward<Args>(args)...);
322
+ }
323
+ },
324
+ is_new_style_constructor(),
325
+ extra...);
326
+ }
327
+
328
+ template <
329
+ typename Class,
330
+ typename... Extra,
331
+ enable_if_t<Class::has_alias && !std::is_constructible<Cpp<Class>, Args...>::value, int>
332
+ = 0>
333
+ static void execute(Class &cl, const Extra &...extra) {
334
+ cl.def(
335
+ "__init__",
336
+ [](value_and_holder &v_h, Args... args) {
337
+ v_h.value_ptr()
338
+ = construct_or_initialize<Alias<Class>>(std::forward<Args>(args)...);
339
+ },
340
+ is_new_style_constructor(),
341
+ extra...);
342
+ }
343
+ };
344
+
345
+ // Implementing class for py::init_alias<...>()
346
+ template <typename... Args>
347
+ struct alias_constructor {
348
+ template <
349
+ typename Class,
350
+ typename... Extra,
351
+ enable_if_t<Class::has_alias && std::is_constructible<Alias<Class>, Args...>::value, int>
352
+ = 0>
353
+ static void execute(Class &cl, const Extra &...extra) {
354
+ cl.def(
355
+ "__init__",
356
+ [](value_and_holder &v_h, Args... args) {
357
+ v_h.value_ptr()
358
+ = construct_or_initialize<Alias<Class>>(std::forward<Args>(args)...);
359
+ },
360
+ is_new_style_constructor(),
361
+ extra...);
362
+ }
363
+ };
364
+
365
+ // Implementation class for py::init(Func) and py::init(Func, AliasFunc)
366
+ template <typename CFunc,
367
+ typename AFunc = void_type (*)(),
368
+ typename = function_signature_t<CFunc>,
369
+ typename = function_signature_t<AFunc>>
370
+ struct factory;
371
+
372
+ // Specialization for py::init(Func)
373
+ template <typename Func, typename Return, typename... Args>
374
+ struct factory<Func, void_type (*)(), Return(Args...)> {
375
+ remove_reference_t<Func> class_factory;
376
+
377
+ // NOLINTNEXTLINE(google-explicit-constructor)
378
+ factory(Func &&f) : class_factory(std::forward<Func>(f)) {}
379
+
380
+ // The given class either has no alias or has no separate alias factory;
381
+ // this always constructs the class itself. If the class is registered with an alias
382
+ // type and an alias instance is needed (i.e. because the final type is a Python class
383
+ // inheriting from the C++ type) the returned value needs to either already be an alias
384
+ // instance, or the alias needs to be constructible from a `Class &&` argument.
385
+ template <typename Class, typename... Extra>
386
+ void execute(Class &cl, const Extra &...extra) && {
387
+ #if defined(PYBIND11_CPP14)
388
+ cl.def(
389
+ "__init__",
390
+ [func = std::move(class_factory)]
391
+ #else
392
+ auto &func = class_factory;
393
+ cl.def(
394
+ "__init__",
395
+ [func]
396
+ #endif
397
+ (value_and_holder &v_h, Args... args) {
398
+ construct<Class>(
399
+ v_h, func(std::forward<Args>(args)...), Py_TYPE(v_h.inst) != v_h.type->type);
400
+ },
401
+ is_new_style_constructor(),
402
+ extra...);
403
+ }
404
+ };
405
+
406
+ // Specialization for py::init(Func, AliasFunc)
407
+ template <typename CFunc,
408
+ typename AFunc,
409
+ typename CReturn,
410
+ typename... CArgs,
411
+ typename AReturn,
412
+ typename... AArgs>
413
+ struct factory<CFunc, AFunc, CReturn(CArgs...), AReturn(AArgs...)> {
414
+ static_assert(sizeof...(CArgs) == sizeof...(AArgs),
415
+ "pybind11::init(class_factory, alias_factory): class and alias factories "
416
+ "must have identical argument signatures");
417
+ static_assert(all_of<std::is_same<CArgs, AArgs>...>::value,
418
+ "pybind11::init(class_factory, alias_factory): class and alias factories "
419
+ "must have identical argument signatures");
420
+
421
+ remove_reference_t<CFunc> class_factory;
422
+ remove_reference_t<AFunc> alias_factory;
423
+
424
+ factory(CFunc &&c, AFunc &&a)
425
+ : class_factory(std::forward<CFunc>(c)), alias_factory(std::forward<AFunc>(a)) {}
426
+
427
+ // The class factory is called when the `self` type passed to `__init__` is the direct
428
+ // class (i.e. not inherited), the alias factory when `self` is a Python-side subtype.
429
+ template <typename Class, typename... Extra>
430
+ void execute(Class &cl, const Extra &...extra) && {
431
+ static_assert(Class::has_alias,
432
+ "The two-argument version of `py::init()` can "
433
+ "only be used if the class has an alias");
434
+ #if defined(PYBIND11_CPP14)
435
+ cl.def(
436
+ "__init__",
437
+ [class_func = std::move(class_factory), alias_func = std::move(alias_factory)]
438
+ #else
439
+ auto &class_func = class_factory;
440
+ auto &alias_func = alias_factory;
441
+ cl.def(
442
+ "__init__",
443
+ [class_func, alias_func]
444
+ #endif
445
+ (value_and_holder &v_h, CArgs... args) {
446
+ if (Py_TYPE(v_h.inst) == v_h.type->type) {
447
+ // If the instance type equals the registered type we don't have inheritance,
448
+ // so don't need the alias and can construct using the class function:
449
+ construct<Class>(v_h, class_func(std::forward<CArgs>(args)...), false);
450
+ } else {
451
+ construct<Class>(v_h, alias_func(std::forward<CArgs>(args)...), true);
452
+ }
453
+ },
454
+ is_new_style_constructor(),
455
+ extra...);
456
+ }
457
+ };
458
+
459
+ /// Set just the C++ state. Same as `__init__`.
460
+ template <typename Class, typename T>
461
+ void setstate(value_and_holder &v_h, T &&result, bool need_alias) {
462
+ construct<Class>(v_h, std::forward<T>(result), need_alias);
463
+ }
464
+
465
+ /// Set both the C++ and Python states
466
+ template <typename Class,
467
+ typename T,
468
+ typename O,
469
+ enable_if_t<std::is_convertible<O, handle>::value, int> = 0>
470
+ void setstate(value_and_holder &v_h, std::pair<T, O> &&result, bool need_alias) {
471
+ construct<Class>(v_h, std::move(result.first), need_alias);
472
+ auto d = handle(result.second);
473
+ if (PyDict_Check(d.ptr()) && PyDict_Size(d.ptr()) == 0) {
474
+ // Skipping setattr below, to not force use of py::dynamic_attr() for Class unnecessarily.
475
+ // See PR #2972 for details.
476
+ return;
477
+ }
478
+ // Our tests never run into an unset dict, but being careful here for now (see #5658)
479
+ auto dict = getattr((PyObject *) v_h.inst, "__dict__", none());
480
+ if (dict.is_none()) {
481
+ setattr((PyObject *) v_h.inst, "__dict__", d);
482
+ } else {
483
+ // Keep the original object dict and just update it
484
+ if (PyDict_Update(dict.ptr(), d.ptr()) < 0) {
485
+ throw error_already_set();
486
+ }
487
+ }
488
+ }
489
+
490
+ /// Implementation for py::pickle(GetState, SetState)
491
+ template <typename Get,
492
+ typename Set,
493
+ typename = function_signature_t<Get>,
494
+ typename = function_signature_t<Set>>
495
+ struct pickle_factory;
496
+
497
+ template <typename Get,
498
+ typename Set,
499
+ typename RetState,
500
+ typename Self,
501
+ typename NewInstance,
502
+ typename ArgState>
503
+ struct pickle_factory<Get, Set, RetState(Self), NewInstance(ArgState)> {
504
+ static_assert(std::is_same<intrinsic_t<RetState>, intrinsic_t<ArgState>>::value,
505
+ "The type returned by `__getstate__` must be the same "
506
+ "as the argument accepted by `__setstate__`");
507
+
508
+ remove_reference_t<Get> get;
509
+ remove_reference_t<Set> set;
510
+
511
+ pickle_factory(Get get, Set set) : get(std::forward<Get>(get)), set(std::forward<Set>(set)) {}
512
+
513
+ template <typename Class, typename... Extra>
514
+ void execute(Class &cl, const Extra &...extra) && {
515
+ cl.def("__getstate__", std::move(get), pos_only());
516
+
517
+ #if defined(PYBIND11_CPP14)
518
+ cl.def(
519
+ "__setstate__",
520
+ [func = std::move(set)]
521
+ #else
522
+ auto &func = set;
523
+ cl.def(
524
+ "__setstate__",
525
+ [func]
526
+ #endif
527
+ (value_and_holder &v_h, ArgState state) {
528
+ setstate<Class>(
529
+ v_h, func(std::forward<ArgState>(state)), Py_TYPE(v_h.inst) != v_h.type->type);
530
+ },
531
+ is_new_style_constructor(),
532
+ extra...);
533
+ }
534
+ };
535
+
536
+ PYBIND11_NAMESPACE_END(initimpl)
537
+ PYBIND11_NAMESPACE_END(detail)
538
+ PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)