summaryrefslogtreecommitdiff
path: root/libs/python/doc/html/reference/high_level_components.html
blob: d9d5d45dcffc5046d2c2a9e4cf876f739796e530 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Chapter&#160;2.&#160;High Level Components</title>
<link rel="stylesheet" href="../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="Boost.Python Reference Manual">
<link rel="up" href="index.html" title="Boost.Python Reference Manual">
<link rel="prev" href="concepts/objectwrapper.html" title="ObjectWrapper">
<link rel="next" href="high_level_components/boost_python_def_hpp.html" title="boost/python/def.hpp">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="" width="" height="" src="../images/boost.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="concepts/objectwrapper.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="high_level_components/boost_python_def_hpp.html"><img src="../images/next.png" alt="Next"></a>
</div>
<div class="chapter">
<div class="titlepage"><div><div><h2 class="title">
<a name="high_level_components"></a>Chapter&#160;2.&#160;High Level Components</h2></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt><span class="section"><a href="high_level_components.html#high_level_components.boost_python_class_hpp">boost/python/class.hpp</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="high_level_components.html#high_level_components.boost_python_class_hpp.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_class_t_bases_hel">Class
        template <code class="computeroutput"><span class="identifier">class_</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">Bases</span><span class="special">,</span> <span class="identifier">HeldType</span><span class="special">,</span> <span class="identifier">NonCopyable</span><span class="special">&gt;</span></code></a></span></dt>
<dt><span class="section"><a href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_bases_t1_t2_tn">Class
        template bases&lt;T1, T2, ...TN&gt;</a></span></dt>
<dt><span class="section"><a href="high_level_components.html#high_level_components.boost_python_class_hpp.examples">Examples</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="high_level_components/boost_python_def_hpp.html">boost/python/def.hpp</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="high_level_components/boost_python_def_hpp.html#high_level_components.boost_python_def_hpp.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_def_hpp.html#high_level_components.boost_python_def_hpp.functions">Functions</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_def_hpp.html#high_level_components.boost_python_def_hpp.example">Example</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="high_level_components/boost_python_def_visitor_hpp.html">boost/python/def_visitor.hpp</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="high_level_components/boost_python_def_visitor_hpp.html#high_level_components.boost_python_def_visitor_hpp.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_def_visitor_hpp.html#high_level_components.boost_python_def_visitor_hpp.class_def_visitor">Class
        <code class="computeroutput"><span class="identifier">def_visitor</span></code></a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_def_visitor_hpp.html#high_level_components.boost_python_def_visitor_hpp.example">Example</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="high_level_components/boost_python_docstring_options_h.html">boost/python/docstring_options.hpp</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="high_level_components/boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.class_docstring_options">Class
        <code class="computeroutput"><span class="identifier">docstring_options</span></code></a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.class_dostring_options_construct">Class
        dostring_options constructors</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.class_docstring_options_destruct">Class
        docstring_options destructor</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.class_docstring_options_modifier">Class
        <code class="computeroutput"><span class="identifier">docstring_options</span></code> modifier
        functions</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_docstring_options_h.html#high_level_components.boost_python_docstring_options_h.example">Example</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="high_level_components/boost_python_enum_hpp.html">boost/python/enum.hpp</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="high_level_components/boost_python_enum_hpp.html#high_level_components.boost_python_enum_hpp.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_enum_hpp.html#high_level_components.boost_python_enum_hpp.class_template_enum">Class
        template <code class="computeroutput"><span class="identifier">enum_</span></code></a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_enum_hpp.html#high_level_components.boost_python_enum_hpp.class_template_enum_constructors">Class
        template <code class="computeroutput"><span class="identifier">enum_</span></code> constructors</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_enum_hpp.html#high_level_components.boost_python_enum_hpp.class_template_enum_modifier_fun">Class
        template <code class="computeroutput"><span class="identifier">enum_</span></code> modifier functions</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_enum_hpp.html#high_level_components.boost_python_enum_hpp.example">Example</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="high_level_components/boost_python_errors_hpp.html">boost/python/errors.hpp</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="high_level_components/boost_python_errors_hpp.html#high_level_components.boost_python_errors_hpp.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_errors_hpp.html#high_level_components.boost_python_errors_hpp.class_error_already_set">Class
        <code class="computeroutput"><span class="identifier">error_already_set</span></code></a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_errors_hpp.html#high_level_components.boost_python_errors_hpp.functions">Functions</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_errors_hpp.html#high_level_components.boost_python_errors_hpp.example">Example</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="high_level_components/boost_python_exception_translato.html">boost/python/exception_translator.hpp</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="high_level_components/boost_python_exception_translato.html#high_level_components.boost_python_exception_translato.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_exception_translato.html#high_level_components.boost_python_exception_translato.function_register_exception_tran">Function
        <code class="computeroutput"><span class="identifier">register_exception_translator</span></code></a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_exception_translato.html#high_level_components.boost_python_exception_translato.example">Example</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="high_level_components/boost_python_init_hpp.html">boost/python/init.hpp</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="high_level_components/boost_python_init_hpp.html#high_level_components.boost_python_init_hpp.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_init_hpp.html#high_level_components.boost_python_init_hpp.class_template_init">Class
        template <code class="computeroutput"><span class="identifier">init</span></code></a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_init_hpp.html#high_level_components.boost_python_init_hpp.class_template_optional">Class
        template <code class="computeroutput"><span class="identifier">optional</span></code> </a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_init_hpp.html#high_level_components.boost_python_init_hpp.example">Example</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="high_level_components/boost_python_iterator_hpp.html">boost/python/iterator.hpp</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="high_level_components/boost_python_iterator_hpp.html#high_level_components.boost_python_iterator_hpp.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_iterator_hpp.html#high_level_components.boost_python_iterator_hpp.class_template_iterator">Class
        template <code class="computeroutput"><span class="identifier">iterator</span></code></a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_iterator_hpp.html#high_level_components.boost_python_iterator_hpp.class_template_iterator_construc">Class
        template iterator constructors</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_iterator_hpp.html#high_level_components.boost_python_iterator_hpp.class_template_iterators">Class
        template <code class="computeroutput"><span class="identifier">iterators</span></code></a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_iterator_hpp.html#high_level_components.boost_python_iterator_hpp.class_template_iterators_nested_">Class
        template iterators nested types</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_iterator_hpp.html#high_level_components.boost_python_iterator_hpp.class_template_iterators_static_">Class
        template iterators static functions</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_iterator_hpp.html#high_level_components.boost_python_iterator_hpp.functions">Functions</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_iterator_hpp.html#high_level_components.boost_python_iterator_hpp.example">Example</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="high_level_components/boost_python_module_hpp.html">boost/python/module.hpp</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="high_level_components/boost_python_module_hpp.html#high_level_components.boost_python_module_hpp.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_module_hpp.html#high_level_components.boost_python_module_hpp.macros">Macros</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_module_hpp.html#high_level_components.boost_python_module_hpp.examples">Examples</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="high_level_components/boost_python_operators_hpp.html">boost/python/operators.hpp</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="high_level_components/boost_python_operators_hpp.html#high_level_components.boost_python_operators_hpp.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_operators_hpp.html#high_level_components.boost_python_operators_hpp.class_self_ns_self_t">Class
        <code class="computeroutput"><span class="identifier">self_ns</span><span class="special">::</span><span class="identifier">self_t</span></code></a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_operators_hpp.html#high_level_components.boost_python_operators_hpp.class_template_other">Class
        template <code class="computeroutput"><span class="identifier">other</span></code></a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_operators_hpp.html#high_level_components.boost_python_operators_hpp.class_template_detail_operator">Class
        template <code class="computeroutput"><span class="identifier">detail</span><span class="special">::</span><span class="identifier">operator_</span></code></a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_operators_hpp.html#high_level_components.boost_python_operators_hpp.object_self">Object
        <code class="computeroutput"><span class="identifier">self</span></code></a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_operators_hpp.html#high_level_components.boost_python_operators_hpp.example">Example</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="high_level_components/boost_python_scope_hpp.html">boost/python/scope.hpp</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="high_level_components/boost_python_scope_hpp.html#high_level_components.boost_python_scope_hpp.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_scope_hpp.html#high_level_components.boost_python_scope_hpp.class_scope">Class
        <code class="computeroutput"><span class="identifier">scope</span></code></a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_scope_hpp.html#high_level_components.boost_python_scope_hpp.class_scope_constructors_and_des">Class
        scope constructors and destructor</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_scope_hpp.html#high_level_components.boost_python_scope_hpp.example">Example</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="high_level_components/boost_python_stl_iterator_hpp.html">boost/python/stl_iterator.hpp</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="high_level_components/boost_python_stl_iterator_hpp.html#high_level_components.boost_python_stl_iterator_hpp.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_stl_iterator_hpp.html#high_level_components.boost_python_stl_iterator_hpp.class_template_stl_input_iterato">Class
        template <code class="computeroutput"><span class="identifier">stl_input_iterator</span></code></a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_stl_iterator_hpp.html#high_level_components.boost_python_stl_iterator_hpp.class_template_stl_input_iterat0">Class
        template <code class="computeroutput"><span class="identifier">stl_input_iterator</span></code>
        constructors</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_stl_iterator_hpp.html#high_level_components.boost_python_stl_iterator_hpp.class_template_stl_input_iterat1">Class
        template <code class="computeroutput"><span class="identifier">stl_input_iterator</span></code>
        modifiers</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_stl_iterator_hpp.html#high_level_components.boost_python_stl_iterator_hpp.class_template_stl_input_iterat2">Class
        template <code class="computeroutput"><span class="identifier">stl_input_iterator</span></code>
        observers</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_stl_iterator_hpp.html#high_level_components.boost_python_stl_iterator_hpp.example">Example</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="high_level_components/boost_python_wrapper_hpp.html">boost/python/wrapper.hpp</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="high_level_components/boost_python_wrapper_hpp.html#high_level_components.boost_python_wrapper_hpp.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_wrapper_hpp.html#high_level_components.boost_python_wrapper_hpp.class_override">Class
        <code class="computeroutput"><span class="identifier">override</span></code></a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_wrapper_hpp.html#high_level_components.boost_python_wrapper_hpp.class_override_observer_function">Class
        <code class="computeroutput"><span class="identifier">override</span></code> observer functions</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_wrapper_hpp.html#high_level_components.boost_python_wrapper_hpp.class_template_wrapper">Class
        template <code class="computeroutput"><span class="identifier">wrapper</span></code></a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_wrapper_hpp.html#high_level_components.boost_python_wrapper_hpp.class_template_wrapper_observer_">Class
        template <code class="computeroutput"><span class="identifier">wrapper</span></code> observer
        functions</a></span></dt>
<dt><span class="section"><a href="high_level_components/boost_python_wrapper_hpp.html#high_level_components.boost_python_wrapper_hpp.example">Example</a></span></dt>
</dl></dd>
</dl>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="high_level_components.boost_python_class_hpp"></a><a class="link" href="high_level_components.html#high_level_components.boost_python_class_hpp" title="boost/python/class.hpp">boost/python/class.hpp</a>
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="high_level_components.html#high_level_components.boost_python_class_hpp.introduction">Introduction</a></span></dt>
<dt><span class="section"><a href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_class_t_bases_hel">Class
        template <code class="computeroutput"><span class="identifier">class_</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">Bases</span><span class="special">,</span> <span class="identifier">HeldType</span><span class="special">,</span> <span class="identifier">NonCopyable</span><span class="special">&gt;</span></code></a></span></dt>
<dt><span class="section"><a href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_bases_t1_t2_tn">Class
        template bases&lt;T1, T2, ...TN&gt;</a></span></dt>
<dt><span class="section"><a href="high_level_components.html#high_level_components.boost_python_class_hpp.examples">Examples</a></span></dt>
</dl></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="high_level_components.boost_python_class_hpp.introduction"></a><a class="link" href="high_level_components.html#high_level_components.boost_python_class_hpp.introduction" title="Introduction">Introduction</a>
</h3></div></div></div>
<p>
          <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="keyword">class</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
          defines the interface through which users expose their C++ classes to Python.
          It declares the <code class="computeroutput"><span class="identifier">class_</span></code>
          class template, which is parameterized on the class type being exposed.
          It also exposes the <code class="computeroutput"><span class="identifier">init</span></code>,
          <code class="computeroutput"><span class="identifier">optional</span></code> and <code class="computeroutput"><span class="identifier">bases</span></code> utility class templates, which
          are used in conjunction with <code class="computeroutput"><span class="identifier">class_</span></code>.
        </p>
<p>
          <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">/</span><span class="identifier">class_fwd</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code> contains a forward declaration of the
          <code class="computeroutput"><span class="identifier">class_</span></code> class template.
        </p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="high_level_components.boost_python_class_hpp.class_template_class_t_bases_hel"></a><a class="link" href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_class_t_bases_hel" title="Class template class_&lt;T, Bases, HeldType, NonCopyable&gt;">Class
        template <code class="computeroutput"><span class="identifier">class_</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">Bases</span><span class="special">,</span> <span class="identifier">HeldType</span><span class="special">,</span> <span class="identifier">NonCopyable</span><span class="special">&gt;</span></code></a>
</h3></div></div></div>
<div class="toc"><dl>
<dt><span class="section"><a href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_class_t_bases_hel.heldtype_semantics">HeldType
          Semantics</a></span></dt>
<dt><span class="section"><a href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_class_t_bases_hel.class_template_class_synopsis">Class
          template <code class="computeroutput"><span class="identifier">class_</span></code> synopsis</a></span></dt>
<dt><span class="section"><a href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_class_t_bases_hel.class_template_class_constructor">Class
          template <code class="computeroutput"><span class="identifier">class_</span></code> constructors</a></span></dt>
<dt><span class="section"><a href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_class_t_bases_hel.class_template_class_modifier_fu">Class
          template <code class="computeroutput"><span class="identifier">class_</span></code> modifier
          functions</a></span></dt>
</dl></div>
<p>
          Creates a Python class associated with the C++ type passed as its first
          parameter. Although it has four template parameters, only the first one
          is required. The three optional arguments can actually be supplied <span class="bold"><strong>in any order</strong></span>; Boost.Python determines the role of
          the argument from its type.
        </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                  <p>
                    Template Parameter
                  </p>
                </th>
<th>
                  <p>
                    Requirements
                  </p>
                </th>
<th>
                  <p>
                    Semantics
                  </p>
                </th>
<th>
                  <p>
                    Default
                  </p>
                </th>
</tr></thead>
<tbody>
<tr>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">T</span></code>
                  </p>
                </td>
<td>
                  <p>
                    A class type.
                  </p>
                </td>
<td>
                  <p>
                    The class being wrapped
                  </p>
                </td>
<td>
                </td>
</tr>
<tr>
<td>
                  <p>
                    Bases
                  </p>
                </td>
<td>
                  <p>
                    A specialization of <a class="link" href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_bases_t1_t2_tn" title="Class template bases&lt;T1, T2, ...TN&gt;">bases&lt;...&gt;</a>
                    which specifies previously-exposed C++ base classes of <code class="computeroutput"><span class="identifier">T</span></code>.
                  </p>
                </td>
<td>
                  <p>
                    Registers <code class="computeroutput"><span class="identifier">from_python</span></code>
                    conversions from wrapped <code class="computeroutput"><span class="identifier">T</span></code>
                    instances to each of its exposed direct and indirect bases. For
                    each polymorphic base <code class="computeroutput"><span class="identifier">B</span></code>,
                    registers conversions from indirectly-held wrapped <code class="computeroutput"><span class="identifier">B</span></code> instances to <code class="computeroutput"><span class="identifier">T</span></code>.
                  </p>
                </td>
<td>
                  <p>
                    <a class="link" href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_bases_t1_t2_tn" title="Class template bases&lt;T1, T2, ...TN&gt;">bases&lt;&gt;</a>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    HeldType
                  </p>
                </td>
<td>
                  <p>
                    Must be <code class="computeroutput"><span class="identifier">T</span></code>, a
                    class derived from <code class="computeroutput"><span class="identifier">T</span></code>,
                    or a <a class="link" href="concepts/dereferenceable.html#concepts.dereferenceable.concept_requirements" title="Concept Requirements">Dereferenceable</a>
                    type for which <code class="computeroutput"><span class="identifier">pointee</span><span class="special">&lt;</span><span class="identifier">HeldType</span><span class="special">&gt;::</span><span class="identifier">type</span></code>
                    is <code class="computeroutput"><span class="identifier">T</span></code> or a class
                    derived from <code class="computeroutput"><span class="identifier">T</span></code>.
                  </p>
                </td>
<td>
                  <p>
                    Specifies the type that is actually embedded in a Python object
                    wrapping a <code class="computeroutput"><span class="identifier">T</span></code>
                    instance when <code class="computeroutput"><span class="identifier">T</span></code>'s
                    constructor is called or when a <code class="computeroutput"><span class="identifier">T</span></code>
                    or <code class="computeroutput"><span class="identifier">T</span><span class="special">*</span></code>
                    is converted to Python without the use of <a class="link" href="function_invocation_and_creation/boost_python_ptr_hpp.html#function_invocation_and_creation.boost_python_ptr_hpp.functions" title="Functions">ptr</a>,
                    <code class="computeroutput"><span class="identifier">ref</span></code>, or <a class="link" href="concepts.html#concepts.callpolicies" title="CallPolicies">Call Policies</a> such as
                    <a class="link" href="function_invocation_and_creation/models_of_callpolicies.html#function_invocation_and_creation.models_of_callpolicies.boost_python_return_internal_ref.class_template_return_internal_r" title="Class template return_internal_reference">return_internal_reference</a>.
                    More details below.
                  </p>
                </td>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">T</span></code>
                  </p>
                </td>
</tr>
<tr>
<td>
                  <p>
                    NonCopyable
                  </p>
                </td>
<td>
                  <p>
                    If supplied, must be <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">noncopyable</span></code>.
                  </p>
                </td>
<td>
                  <p>
                    Suppresses automatic registration of <code class="computeroutput"><span class="identifier">to_python</span></code>
                    conversions which copy <code class="computeroutput"><span class="identifier">T</span></code>
                    instances. Required when <code class="computeroutput"><span class="identifier">T</span></code>
                    has no publicly-accessible copy constructor.
                  </p>
                </td>
<td>
                  <p>
                    An unspecified type other than boost::noncopyable.
                  </p>
                </td>
</tr>
</tbody>
</table></div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="high_level_components.boost_python_class_hpp.class_template_class_t_bases_hel.heldtype_semantics"></a><a class="link" href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_class_t_bases_hel.heldtype_semantics" title="HeldType Semantics">HeldType
          Semantics</a>
</h4></div></div></div>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
                If HeldType is derived from <code class="computeroutput"><span class="identifier">T</span></code>,
                its exposed constructor(s) must accept an initial <code class="computeroutput"><span class="identifier">PyObject</span><span class="special">*</span></code> argument which refers back to the
                Python object that contains the HeldType instance, as shown in this
                example. This argument is not included in the <a class="link" href="high_level_components/boost_python_init_hpp.html#high_level_components.boost_python_init_hpp.introduction.init_expressions" title="init-expressions">init-expression</a>
                passed to <a class="link" href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_class_t_bases_hel.class_template_class_modifier_fu" title="Class template class_ modifier functions">def(init_expr)</a>,
                below, nor is it passed explicitly by users when Python instances
                of <code class="computeroutput"><span class="identifier">T</span></code> are created.
                This idiom allows C++ virtual functions which will be overridden
                in Python to access the Python object so the Python method can be
                invoked. Boost.Python automatically registers additional converters
                which allow wrapped instances of <code class="computeroutput"><span class="identifier">T</span></code>
                to be passed to wrapped C++ functions expecting HeldType arguments.
              </li>
<li class="listitem">
                Because Boost.Python will always allow wrapped instances of <code class="computeroutput"><span class="identifier">T</span></code> to be passed in place of HeldType
                arguments, specifying a smart pointer for HeldType allows users to
                pass Python <code class="computeroutput"><span class="identifier">T</span></code> instances
                where a smart pointer-to-T is expected. Smart pointers such as <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">auto_ptr</span><span class="special">&lt;&gt;</span></code>
                or <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">shared_ptr</span><span class="special">&lt;&gt;</span></code>
                which contain a nested type <code class="computeroutput"><span class="identifier">element_type</span></code>
                designating the referent type are automatically supported; additional
                smart pointer types can be supported by specializing <code class="computeroutput"><span class="identifier">pointee</span><span class="special">&lt;</span><span class="identifier">HeldType</span><span class="special">&gt;</span></code>.
              </li>
<li class="listitem">
                As in case 1 above, when HeldType is a smart pointer to a class derived
                from <code class="computeroutput"><span class="identifier">T</span></code>, the initial
                <code class="computeroutput"><span class="identifier">PyObject</span><span class="special">*</span></code>
                argument must be supplied by all of HeldType's exposed constructors.
              </li>
<li class="listitem">
                Except in cases 1 and 3, users may optionally specify that T itself
                gets initialized with a similar initial <code class="computeroutput"><span class="identifier">PyObject</span><span class="special">*</span></code> argument by specializing <a class="link" href="utility_and_infrastructure.html#utility_and_infrastructure.boost_python_has_back_reference_.class_template_has_back_referenc" title="Class template has_back_reference">has_back_reference&lt;T&gt;</a>.
              </li>
</ol></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="high_level_components.boost_python_class_hpp.class_template_class_t_bases_hel.class_template_class_synopsis"></a><a class="link" href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_class_t_bases_hel.class_template_class_synopsis" title="Class template class_ synopsis">Class
          template <code class="computeroutput"><span class="identifier">class_</span></code> synopsis</a>
</h4></div></div></div>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">python</span>
<span class="special">{</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span>
    <span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Bases</span> <span class="special">=</span> <span class="identifier">bases</span><span class="special">&lt;&gt;</span>
          <span class="special">,</span> <span class="keyword">class</span> <span class="identifier">HeldType</span> <span class="special">=</span> <span class="identifier">T</span>
          <span class="special">,</span> <span class="keyword">class</span> <span class="identifier">NonCopyable</span> <span class="special">=</span> <span class="identifier">unspecified</span>
         <span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">class_</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">object</span>
<span class="special">{</span>
  <span class="comment">// Constructors with default __init__</span>
  <span class="identifier">class_</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">);</span>
  <span class="identifier">class_</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">docstring</span><span class="special">);</span>

  <span class="comment">// Constructors, specifying non-default __init__</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Init</span><span class="special">&gt;</span>
  <span class="identifier">class_</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Init</span><span class="special">);</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Init</span><span class="special">&gt;</span>
  <span class="identifier">class_</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">docstring</span><span class="special">,</span> <span class="identifier">Init</span><span class="special">);</span>

  <span class="comment">// Exposing additional __init__ functions</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Init</span><span class="special">&gt;</span>
  <span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def</span><span class="special">(</span><span class="identifier">Init</span><span class="special">);</span>

  <span class="comment">// defining methods</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span>
  <span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">F</span> <span class="identifier">f</span><span class="special">);</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Fn</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">&gt;</span>
  <span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Fn</span> <span class="identifier">fn</span><span class="special">,</span> <span class="identifier">A1</span> <span class="keyword">const</span><span class="special">&amp;);</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Fn</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A2</span><span class="special">&gt;</span>
  <span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Fn</span> <span class="identifier">fn</span><span class="special">,</span> <span class="identifier">A1</span> <span class="keyword">const</span><span class="special">&amp;,</span> <span class="identifier">A2</span> <span class="keyword">const</span><span class="special">&amp;);</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Fn</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A3</span><span class="special">&gt;</span>
  <span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Fn</span> <span class="identifier">fn</span><span class="special">,</span> <span class="identifier">A1</span> <span class="keyword">const</span><span class="special">&amp;,</span> <span class="identifier">A2</span> <span class="keyword">const</span><span class="special">&amp;,</span> <span class="identifier">A3</span> <span class="keyword">const</span><span class="special">&amp;);</span>

  <span class="comment">// declaring method as static</span>
  <span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">staticmethod</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">);</span>

  <span class="comment">// exposing operators</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="identifier">unspecified</span><span class="special">&gt;</span>
  <span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def</span><span class="special">(</span><span class="identifier">detail</span><span class="special">::</span><span class="identifier">operator_</span><span class="special">&lt;</span><span class="identifier">unspecified</span><span class="special">&gt;);</span>

  <span class="comment">// Raw attribute modification</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">&gt;</span>
  <span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">setattr</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">U</span> <span class="keyword">const</span><span class="special">&amp;);</span>

  <span class="comment">// exposing data members</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">D</span><span class="special">&gt;</span>
  <span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def_readonly</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">D</span> <span class="identifier">T</span><span class="special">::*</span><span class="identifier">pm</span><span class="special">);</span>

  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">D</span><span class="special">&gt;</span>
  <span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def_readwrite</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">D</span> <span class="identifier">T</span><span class="special">::*</span><span class="identifier">pm</span><span class="special">);</span>

  <span class="comment">// exposing static data members</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">D</span><span class="special">&gt;</span>
  <span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def_readonly</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">D</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">d</span><span class="special">);</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">D</span><span class="special">&gt;</span>
  <span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def_readwrite</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">D</span><span class="special">&amp;</span> <span class="identifier">d</span><span class="special">);</span>

  <span class="comment">// property creation</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Get</span><span class="special">&gt;</span>
  <span class="keyword">void</span> <span class="identifier">add_property</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Get</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">fget</span><span class="special">,</span> <span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">doc</span><span class="special">=</span><span class="number">0</span><span class="special">);</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Get</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Set</span><span class="special">&gt;</span>
  <span class="keyword">void</span> <span class="identifier">add_property</span><span class="special">(</span>
      <span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Get</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">fget</span><span class="special">,</span> <span class="identifier">Set</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">fset</span><span class="special">,</span> <span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">doc</span><span class="special">=</span><span class="number">0</span><span class="special">);</span>

  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Get</span><span class="special">&gt;</span>
  <span class="keyword">void</span> <span class="identifier">add_static_property</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Get</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">fget</span><span class="special">);</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Get</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Set</span><span class="special">&gt;</span>
  <span class="keyword">void</span> <span class="identifier">add_static_property</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Get</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">fget</span><span class="special">,</span> <span class="identifier">Set</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">fset</span><span class="special">);</span>

  <span class="comment">// pickle support</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">PickleSuite</span><span class="special">&gt;</span>
  <span class="identifier">self</span><span class="special">&amp;</span> <span class="identifier">def_pickle</span><span class="special">(</span><span class="identifier">PickleSuite</span> <span class="keyword">const</span><span class="special">&amp;);</span>
  <span class="identifier">self</span><span class="special">&amp;</span> <span class="identifier">enable_pickling</span><span class="special">();</span>
<span class="special">};</span>
<span class="special">}}</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="high_level_components.boost_python_class_hpp.class_template_class_t_bases_hel.class_template_class_constructor"></a><a class="link" href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_class_t_bases_hel.class_template_class_constructor" title="Class template class_ constructors">Class
          template <code class="computeroutput"><span class="identifier">class_</span></code> constructors</a>
</h4></div></div></div>
<pre class="programlisting"><span class="identifier">class_</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">);</span>
<span class="identifier">class_</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">docstring</span><span class="special">);</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Init</span><span class="special">&gt;</span>
<span class="identifier">class_</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Init</span> <span class="identifier">init_spec</span><span class="special">);</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Init</span><span class="special">&gt;</span>
<span class="identifier">class_</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">docstring</span><span class="special">,</span> <span class="identifier">Init</span> <span class="identifier">init_spec</span><span class="special">);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl>
<dt><span class="term">Requires</span></dt>
<dd><p>
                  name is an <a class="link" href="glossary.html#ntbs">ntbs</a> which conforms to Python's
                  <a href="http://www.python.org/doc/current/ref/identifiers.html" target="_top">identifier
                  naming rules</a>. If docstring is supplied, it must be an
                  <a class="link" href="glossary.html#ntbs">ntbs</a>. If <code class="computeroutput"><span class="identifier">init_spec</span></code>
                  is supplied, it must be either the special enumeration constant
                  <code class="computeroutput"><span class="identifier">no_init</span></code> or an
                  <a class="link" href="high_level_components/boost_python_init_hpp.html#high_level_components.boost_python_init_hpp.introduction.init_expressions" title="init-expressions">init-expression</a>
                  compatible with <code class="computeroutput"><span class="identifier">T</span></code>.
                </p></dd>
<dt><span class="term">Effects</span></dt>
<dd>
<p>
                  Constructs a <code class="computeroutput"><span class="identifier">class_</span></code>
                  object holding a Boost.Python extension class named name. The named
                  attribute of the <a class="link" href="high_level_components/boost_python_scope_hpp.html#high_level_components.boost_python_scope_hpp.introduction" title="Introduction">current
                  scope</a> is bound to the new extension class.
                </p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
                      If supplied, the value of docstring is bound to the <code class="computeroutput"><span class="identifier">__doc__</span></code> attribute of the
                      extension class.
                    </li>
<li class="listitem">
                      If <code class="computeroutput"><span class="identifier">init_spec</span></code>
                      is <code class="computeroutput"><span class="identifier">no_init</span></code>,
                      a special <code class="computeroutput"><span class="identifier">__init__</span></code>
                      function is generated which always raises a Python exception.
                      Otherwise, <code class="computeroutput"><span class="keyword">this</span><span class="special">-&gt;</span><span class="identifier">def</span><span class="special">(</span><span class="identifier">init_spec</span><span class="special">)</span></code> is called.
                    </li>
<li class="listitem">
                      If <code class="computeroutput"><span class="identifier">init_spec</span></code>
                      is not supplied, <code class="computeroutput"><span class="keyword">this</span><span class="special">-&gt;</span><span class="identifier">def</span><span class="special">(</span><span class="identifier">init</span><span class="special">&lt;&gt;())</span></code> is called.
                    </li>
</ul></div>
</dd>
<dt><span class="term">Rationale</span></dt>
<dd><p>
                  Allowing the user to specify constructor arguments in the <code class="computeroutput"><span class="identifier">class_</span><span class="special">&lt;&gt;</span></code>
                  constructor helps her to avoid the common run-time errors which
                  result from invoking wrapped member functions without having exposed
                  an <code class="computeroutput"><span class="identifier">__init__</span></code> function
                  which creates the requisite <code class="computeroutput"><span class="identifier">T</span></code>
                  instance. Types which are not default-constructible will cause
                  a compile-time error unless <code class="computeroutput"><span class="identifier">Init</span></code>
                  is supplied. The user must always supply name as there is currently
                  no portable method to derive the text of the class name from its
                  type.
                </p></dd>
</dl>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="high_level_components.boost_python_class_hpp.class_template_class_t_bases_hel.class_template_class_modifier_fu"></a><a class="link" href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_class_t_bases_hel.class_template_class_modifier_fu" title="Class template class_ modifier functions">Class
          template <code class="computeroutput"><span class="identifier">class_</span></code> modifier
          functions</a>
</h4></div></div></div>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Init</span><span class="special">&gt;</span>
<span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def</span><span class="special">(</span><span class="identifier">Init</span> <span class="identifier">init_expr</span><span class="special">);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl>
<dt><span class="term">Requires</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="identifier">init_expr</span></code> is the
                  result of an <a class="link" href="high_level_components/boost_python_init_hpp.html#high_level_components.boost_python_init_hpp.introduction.init_expressions" title="init-expressions">init-expression</a>
                  compatible with <code class="computeroutput"><span class="identifier">T</span></code>.
                </p></dd>
<dt><span class="term">Effects</span></dt>
<dd><p>
                  For each <a class="link" href="high_level_components/boost_python_init_hpp.html#high_level_components.boost_python_init_hpp.introduction.init_expressions" title="init-expressions">valid
                  prefix</a> <code class="computeroutput"><span class="identifier">P</span></code>
                  of <code class="computeroutput"><span class="identifier">Init</span></code>, adds an
                  <code class="computeroutput"><span class="identifier">__init__</span><span class="special">(...)</span></code>
                  function overload to the extension class accepting P as arguments.
                  Each overload generated constructs an object of HeldType according
                  to the semantics described above, using a copy of init_expr's call
                  policies. If the longest <a class="link" href="high_level_components/boost_python_init_hpp.html#high_level_components.boost_python_init_hpp.introduction.init_expressions" title="init-expressions">valid
                  prefix</a> of Init contains N types and init_expr holds M keywords,
                  an initial sequence of the keywords are used for all but the first
                  N - M arguments of each overload.
                </p></dd>
<dt><span class="term">Returns</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
                </p></dd>
<dt><span class="term">Rationale</span></dt>
<dd><p>
                  Allows users to easily expose a class' constructor to Python.
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">F</span><span class="special">&gt;</span>
<span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Fn</span> <span class="identifier">fn</span><span class="special">);</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Fn</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">&gt;</span>
<span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Fn</span> <span class="identifier">fn</span><span class="special">,</span> <span class="identifier">A1</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">a1</span><span class="special">);</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Fn</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A2</span><span class="special">&gt;</span>
<span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Fn</span> <span class="identifier">fn</span><span class="special">,</span> <span class="identifier">A1</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">a1</span><span class="special">,</span> <span class="identifier">A2</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">a2</span><span class="special">);</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Fn</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">A3</span><span class="special">&gt;</span>
<span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Fn</span> <span class="identifier">fn</span><span class="special">,</span> <span class="identifier">A1</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">a1</span><span class="special">,</span> <span class="identifier">A2</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">a2</span><span class="special">,</span> <span class="identifier">A3</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">a3</span><span class="special">);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl>
<dt><span class="term">Requires</span></dt>
<dd>
<p>
                  name is an <a class="link" href="glossary.html#ntbs">ntbs</a> which conforms to Python's
                  <a href="http://www.python.org/doc/current/ref/identifiers.html" target="_top">identifier
                  naming rules</a>. * If a1 is the result of an <a class="link" href="function_invocation_and_creation/boost_python_overloads_hpp.html#function_invocation_and_creation.boost_python_overloads_hpp.introduction.overload_dispatch_expressions" title="overload-dispatch-expressions">overload-dispatch-expression</a>,
                  only the second form is allowed and fn must be a pointer to function
                  or pointer to member function whose <a class="link" href="glossary.html#arity">arity</a>
                  is the same as A1's <a class="link" href="function_invocation_and_creation/boost_python_overloads_hpp.html#function_invocation_and_creation.boost_python_overloads_hpp.introduction.overload_dispatch_expressions" title="overload-dispatch-expressions">maximum
                  arity</a>.
                </p>
<p>
                  <span class="bold"><strong>Effects:</strong></span> For each prefix <code class="computeroutput"><span class="identifier">P</span></code> of <code class="computeroutput"><span class="identifier">Fn</span></code>'s
                  sequence of argument types, beginning with the one whose length
                  is <code class="computeroutput"><span class="identifier">A1</span></code>'s <a class="link" href="function_invocation_and_creation/boost_python_overloads_hpp.html#function_invocation_and_creation.boost_python_overloads_hpp.introduction.overload_dispatch_expressions" title="overload-dispatch-expressions">minimum
                  arity</a>, adds a <code class="computeroutput"><span class="identifier">name</span><span class="special">(...)</span></code> method overload to the extension
                  class. Each overload generated invokes a1's call-expression with
                  <code class="computeroutput"><span class="identifier">P</span></code>, using a copy
                  of a1's call policies. If the longest valid prefix of <code class="computeroutput"><span class="identifier">A1</span></code> contains <code class="computeroutput"><span class="identifier">N</span></code>
                  types and a1 holds <code class="computeroutput"><span class="identifier">M</span></code>
                  keywords, an initial sequence of the keywords are used for all
                  but the first <code class="computeroutput"><span class="identifier">N</span> <span class="special">-</span> <span class="identifier">M</span></code>
                  arguments of each overload.
                </p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
                      Otherwise, a single method overload is built around fn, which
                      must not be null:
                      <div class="itemizedlist"><ul class="itemizedlist" type="circle">
<li class="listitem">
                            If fn is a function pointer, its first argument must
                            be of the form U, U cv&amp;, U cv*, or U cv* const&amp;,
                            where T* is convertible to U*, and a1-a3, if supplied,
                            may be selected in any order from the table below.
                          </li>
<li class="listitem">
                            Otherwise, if fn is a member function pointer, its target
                            must be T or one of its public base classes, and a1-a3,
                            if supplied, may be selected in any order from the table
                            below.
                          </li>
<li class="listitem">
<p class="simpara">
                            Otherwise, Fn must be [derived from] <a class="link" href="object_wrappers/boost_python_object_hpp.html#object_wrappers.boost_python_object_hpp.class_object" title="Class object">object</a>,
                            and a1-a2, if supplied, may be selcted in any order from
                            the first two rows of the table below. To be useful,
                            fn should be <a href="http://www.python.org/doc/current/lib/built-in-funcs.html#l2h-6" target="_top">callable</a>.
                          </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                                    <p>
                                      Mnemonic Name
                                    </p>
                                  </th>
<th>
                                    <p>
                                      Requirements/Type properties
                                    </p>
                                  </th>
<th>
                                    <p>
                                      Effects
                                    </p>
                                  </th>
</tr></thead>
<tbody>
<tr>
<td>
                                    <p>
                                      docstring
                                    </p>
                                  </td>
<td>
                                    <p>
                                      Any <a class="link" href="glossary.html#ntbs">ntbs</a>
                                    </p>
                                  </td>
<td>
                                    <p>
                                      Value will be bound to the __doc__ attribute
                                      of the resulting method overload. If an earlier
                                      overload supplied a docstring, two newline
                                      characters and the new docstring are appended
                                      to it.
                                    </p>
                                  </td>
</tr>
<tr>
<td>
                                    <p>
                                      policies
                                    </p>
                                  </td>
<td>
                                    <p>
                                      A model of <a class="link" href="concepts.html#concepts.callpolicies" title="CallPolicies">CallPolicies</a>
                                    </p>
                                  </td>
<td>
                                    <p>
                                      A copy will be used as the call policies of
                                      the resulting method overload.
                                    </p>
                                  </td>
</tr>
<tr>
<td>
                                    <p>
                                      keywords
                                    </p>
                                  </td>
<td>
                                    <p>
                                      The result of a <a class="link" href="function_invocation_and_creation.html#function_invocation_and_creation.boost_python_args_hpp.introduction.keyword_expressions" title="keyword-expressions">keyword-expression</a>
                                      specifying no more arguments than the <a class="link" href="glossary.html#arity">arity</a> of fn.
                                    </p>
                                  </td>
<td>
                                    <p>
                                      A copy will be used as the call policies of
                                      the resulting method overload.
                                    </p>
                                  </td>
</tr>
</tbody>
</table></div>
</li>
</ul></div>
                    </li></ul></div>
</dd>
<dt><span class="term">Returns</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">staticmethod</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">);</span></pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl>
<dt><span class="term">Requires</span></dt>
<dd><p>
                  name is an <a class="link" href="glossary.html#ntbs">ntbs</a> which conforms to Python's
                  <a href="http://www.python.org/doc/current/ref/identifiers.html" target="_top">identifier
                  naming rules</a>, and corresponds to a method whose overloads
                  have all been defined.
                </p></dd>
<dt><span class="term">Effects</span></dt>
<dd><p>
                  Replaces the existing named attribute <code class="computeroutput"><span class="identifier">x</span></code>
                  with the result of invoking <code class="computeroutput"><span class="identifier">staticmethod</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code> in Python. Specifies that the
                  corresponding method is static and therefore no object instance
                  will be passed to it. This is equivalent to the Python statement:
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="identifier">setattr</span><span class="special">(</span><span class="identifier">self</span><span class="special">,</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">staticmethod</span><span class="special">(</span><span class="identifier">getattr</span><span class="special">(</span><span class="identifier">self</span><span class="special">,</span> <span class="identifier">name</span><span class="special">)))</span></pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl>
<dt><span class="term">Note</span></dt>
<dd><p>
                  Attempting to invoke def(name,...) after invoking staticmethod(name)
                  will <a class="link" href="glossary.html#raise">raise</a> a RuntimeError.
                </p></dd>
<dt><span class="term">Returns</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="identifier">unspecified</span><span class="special">&gt;</span>
<span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def</span><span class="special">(</span><span class="identifier">detail</span><span class="special">::</span><span class="identifier">operator_</span><span class="special">&lt;</span><span class="identifier">unspecified</span><span class="special">&gt;);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl>
<dt><span class="term">Effects</span></dt>
<dd><p>
                  Adds a Python <a href="http://www.python.org/doc/ref/specialnames.html" target="_top">special
                  method</a> as described <a class="link" href="high_level_components/boost_python_operators_hpp.html" title="boost/python/operators.hpp">here</a>.
                </p></dd>
<dt><span class="term">Returns</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">U</span><span class="special">&gt;</span>
<span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">setattr</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">U</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">u</span><span class="special">);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl>
<dt><span class="term">Requires</span></dt>
<dd><p>
                  name is an <a class="link" href="glossary.html#ntbs">ntbs</a> which conforms to Python's
                  <a href="http://www.python.org/doc/current/ref/identifiers.html" target="_top">identifier
                  naming rules</a>.
                </p></dd>
<dt><span class="term">Effects</span></dt>
<dd>
<p>
                  Converts <code class="computeroutput"><span class="identifier">u</span></code> to Python
                  and adds it to the attribute dictionary of the extension class:
                </p>
<pre class="programlisting"><span class="identifier">PyObject_SetAttrString</span><span class="special">(</span><span class="keyword">this</span><span class="special">-&gt;</span><span class="identifier">ptr</span><span class="special">(),</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">object</span><span class="special">(</span><span class="identifier">u</span><span class="special">).</span><span class="identifier">ptr</span><span class="special">());</span></pre>
</dd>
<dt><span class="term">Returns</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Get</span><span class="special">&gt;</span>
<span class="keyword">void</span> <span class="identifier">add_property</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Get</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">fget</span><span class="special">,</span> <span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">doc</span><span class="special">=</span><span class="number">0</span><span class="special">);</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Get</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Set</span><span class="special">&gt;</span>
<span class="keyword">void</span> <span class="identifier">add_property</span><span class="special">(</span>
      <span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Get</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">fget</span><span class="special">,</span> <span class="identifier">Set</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">fset</span><span class="special">,</span> <span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">doc</span><span class="special">=</span><span class="number">0</span><span class="special">);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl>
<dt><span class="term">Requires</span></dt>
<dd><p>
                  name is an <a class="link" href="glossary.html#ntbs">ntbs</a> which conform to Python's
                  <a href="http://www.python.org/doc/current/ref/identifiers.html" target="_top">identifier
                  naming rules</a>.
                </p></dd>
<dt><span class="term">Effects</span></dt>
<dd><p>
                  Creates a new Python <a href="http://www.python.org/2.2.2/descrintro.html#property" target="_top">property</a>
                  class instance, passing <code class="computeroutput"><span class="identifier">object</span><span class="special">(</span><span class="identifier">fget</span><span class="special">)</span></code> (and <code class="computeroutput"><span class="identifier">object</span><span class="special">(</span><span class="identifier">fset</span><span class="special">)</span></code> in the second form) with an (optional)
                  docstring <code class="computeroutput"><span class="identifier">doc</span></code> to
                  its constructor, then adds that property to the Python class object
                  under construction with the given attribute name.
                </p></dd>
<dt><span class="term">Returns</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
                </p></dd>
<dt><span class="term">Rationale</span></dt>
<dd><p>
                  Allows users to easily expose functions that can be invoked from
                  Python with attribute access syntax.
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Get</span><span class="special">&gt;</span>
<span class="keyword">void</span> <span class="identifier">add_static_property</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Get</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">fget</span><span class="special">);</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Get</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Set</span><span class="special">&gt;</span>
<span class="keyword">void</span> <span class="identifier">add_static_property</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">Get</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">fget</span><span class="special">,</span> <span class="identifier">Set</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">fset</span><span class="special">);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl>
<dt><span class="term">Requires</span></dt>
<dd><p>
                  name is an <a class="link" href="glossary.html#ntbs">ntbs</a> which conforms to Python's
                  <a href="http://www.python.org/doc/current/ref/identifiers.html" target="_top">identifier
                  naming rules</a>.
                </p></dd>
<dt><span class="term">Effects</span></dt>
<dd><p>
                  Creates a Boost.Python.StaticProperty object, passing <code class="computeroutput"><span class="identifier">object</span><span class="special">(</span><span class="identifier">fget</span><span class="special">)</span></code>
                  (and <code class="computeroutput"><span class="identifier">object</span><span class="special">(</span><span class="identifier">fset</span><span class="special">)</span></code>
                  in the second form) to its constructor, then adds that property
                  to the Python class under construction with the given attribute
                  name. StaticProperty is a special subclass of Python's property
                  class which can be called without an initial self argument.
                </p></dd>
<dt><span class="term">Returns</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
                </p></dd>
<dt><span class="term">Rationale</span></dt>
<dd><p>
                  Allows users to easily expose functions that can be invoked from
                  Python with static attribute access syntax.
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">D</span><span class="special">&gt;</span>
<span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def_readonly</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">D</span> <span class="identifier">T</span><span class="special">::*</span><span class="identifier">pm</span><span class="special">,</span> <span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">doc</span><span class="special">=</span><span class="number">0</span><span class="special">);</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">D</span><span class="special">&gt;</span>
<span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def_readonly</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">D</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">d</span><span class="special">);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl>
<dt><span class="term">Requires</span></dt>
<dd><p>
                  name is an <a class="link" href="glossary.html#ntbs">ntbs</a> which conforms to Python's
                  <a href="http://www.python.org/doc/current/ref/identifiers.html" target="_top">identifier
                  naming rules</a>. <code class="computeroutput"><span class="identifier">doc</span></code>
                  is also an <a class="link" href="glossary.html#ntbs">ntbs</a>.
                </p></dd>
<dt><span class="term">Effects</span></dt>
<dd>
<pre class="programlisting"><span class="keyword">this</span><span class="special">-&gt;</span><span class="identifier">add_property</span><span class="special">(</span><span class="identifier">name</span><span class="special">,</span> <span class="identifier">make_getter</span><span class="special">(</span><span class="identifier">pm</span><span class="special">),</span> <span class="identifier">doc</span><span class="special">);</span></pre>
<p>
                  and
                </p>
<pre class="programlisting"><span class="keyword">this</span><span class="special">-&gt;</span><span class="identifier">add_static_property</span><span class="special">(</span><span class="identifier">name</span><span class="special">,</span> <span class="identifier">make_getter</span><span class="special">(</span><span class="identifier">d</span><span class="special">));</span></pre>
<p>
                  respectively.
                </p>
</dd>
<dt><span class="term">Returns</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
                </p></dd>
<dt><span class="term">Rationale</span></dt>
<dd><p>
                  Allows users to easily expose a class' data member or free variable
                  such that it can be inspected from Python with a natural syntax.
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">D</span><span class="special">&gt;</span>
<span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def_readwrite</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">D</span> <span class="identifier">T</span><span class="special">::*</span><span class="identifier">pm</span><span class="special">,</span> <span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">doc</span><span class="special">=</span><span class="number">0</span><span class="special">);</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">D</span><span class="special">&gt;</span>
<span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def_readwrite</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">name</span><span class="special">,</span> <span class="identifier">D</span><span class="special">&amp;</span> <span class="identifier">d</span><span class="special">);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl>
<dt><span class="term">Effects</span></dt>
<dd>
<pre class="programlisting"><span class="keyword">this</span><span class="special">-&gt;</span><span class="identifier">add_property</span><span class="special">(</span><span class="identifier">name</span><span class="special">,</span> <span class="identifier">make_getter</span><span class="special">(</span><span class="identifier">pm</span><span class="special">),</span> <span class="identifier">make_setter</span><span class="special">(</span><span class="identifier">pm</span><span class="special">),</span> <span class="identifier">doc</span><span class="special">);</span></pre>
<p>
                  and
                </p>
<pre class="programlisting"><span class="keyword">this</span><span class="special">-&gt;</span><span class="identifier">add_static_property</span><span class="special">(</span><span class="identifier">name</span><span class="special">,</span> <span class="identifier">make_getter</span><span class="special">(</span><span class="identifier">d</span><span class="special">),</span> <span class="identifier">make_setter</span><span class="special">(</span><span class="identifier">d</span><span class="special">));</span></pre>
<p>
                  respectively.
                </p>
</dd>
<dt><span class="term">Returns</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
                </p></dd>
<dt><span class="term">Rationale</span></dt>
<dd><p>
                  Allows users to easily expose a class' data or free variable member
                  such that it can be inspected and set from Python with a natural
                  syntax.
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">PickleSuite</span><span class="special">&gt;</span>
<span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">def_pickle</span><span class="special">(</span><span class="identifier">PickleSuite</span> <span class="keyword">const</span><span class="special">&amp;);</span>
</pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl>
<dt><span class="term">Requires</span></dt>
<dd><p>
                  PickleSuite must be publically derived from <a class="link" href="topics/pickle_support.html#topics.pickle_support.the_pickle_interface" title="The Pickle Interface">pickle_suite</a>.
                </p></dd>
<dt><span class="term">Effects</span></dt>
<dd><p>
                  Defines a legal combination of the special attributes and methods:
                  __getinitargs__, __getstate__, __setstate__, __getstate_manages_dict__,
                  __safe_for_unpickling__, __reduce__
                </p></dd>
<dt><span class="term">Returns</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
                </p></dd>
<dt><span class="term">Rationale</span></dt>
<dd><p>
                  Provides an <a class="link" href="topics/pickle_support.html#topics.pickle_support.the_pickle_interface" title="The Pickle Interface">easy
                  to use high-level interface</a> for establishing complete <a class="link" href="topics/pickle_support.html#topics.pickle_support.the_pickle_interface" title="The Pickle Interface">pickle support</a>
                  for the wrapped class. The user is protected by compile-time consistency
                  checks.
                </p></dd>
</dl>
</div>
<pre class="programlisting"><span class="identifier">class_</span><span class="special">&amp;</span> <span class="identifier">enable_pickling</span><span class="special">();</span></pre>
<div class="variablelist">
<p class="title"><b></b></p>
<dl>
<dt><span class="term">Effects</span></dt>
<dd><p>
                  Defines the __reduce__ method and the __safe_for_unpickling__ attribute.
                </p></dd>
<dt><span class="term">Returns</span></dt>
<dd><p>
                  <code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
                </p></dd>
<dt><span class="term">Rationale</span></dt>
<dd><p>
                  Light-weight alternative to def_pickle(). Enables implementation
                  of pickle support from Python.
                </p></dd>
</dl>
</div>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="high_level_components.boost_python_class_hpp.class_template_bases_t1_t2_tn"></a><a class="link" href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_bases_t1_t2_tn" title="Class template bases&lt;T1, T2, ...TN&gt;">Class
        template bases&lt;T1, T2, ...TN&gt;</a>
</h3></div></div></div>
<div class="toc"><dl><dt><span class="section"><a href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_bases_t1_t2_tn.class_template_bases_synopsis">Class
          template bases synopsis</a></span></dt></dl></div>
<p>
          An MPL sequence which can be used in class_&lt;...&gt; instantiations indicate
          a list of base classes.
        </p>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="high_level_components.boost_python_class_hpp.class_template_bases_t1_t2_tn.class_template_bases_synopsis"></a><a class="link" href="high_level_components.html#high_level_components.boost_python_class_hpp.class_template_bases_t1_t2_tn.class_template_bases_synopsis" title="Class template bases synopsis">Class
          template bases synopsis</a>
</h4></div></div></div>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">python</span>
<span class="special">{</span>
  <span class="keyword">template</span> <span class="special">&lt;</span><span class="identifier">T1</span> <span class="special">=</span> <span class="identifier">unspecified</span><span class="special">,...</span><span class="identifier">Tn</span> <span class="special">=</span> <span class="identifier">unspecified</span><span class="special">&gt;</span>
  <span class="keyword">struct</span> <span class="identifier">bases</span>
  <span class="special">{};</span>
<span class="special">}}</span>
</pre>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="high_level_components.boost_python_class_hpp.examples"></a><a class="link" href="high_level_components.html#high_level_components.boost_python_class_hpp.examples" title="Examples">Examples</a>
</h3></div></div></div>
<p>
          Given a C++ class declaration:
        </p>
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">Foo</span> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">Bar</span><span class="special">,</span> <span class="keyword">public</span> <span class="identifier">Baz</span>
<span class="special">{</span>
 <span class="keyword">public</span><span class="special">:</span>
   <span class="identifier">Foo</span><span class="special">(</span><span class="keyword">int</span> <span class="identifier">x</span><span class="special">,</span> <span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">y</span><span class="special">);</span>
   <span class="identifier">Foo</span><span class="special">(</span><span class="keyword">double</span><span class="special">);</span>

   <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">name</span><span class="special">()</span> <span class="special">{</span> <span class="keyword">return</span> <span class="identifier">m_name</span><span class="special">;</span> <span class="special">}</span>
   <span class="keyword">void</span> <span class="identifier">name</span><span class="special">(</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*);</span>

   <span class="keyword">double</span> <span class="identifier">value</span><span class="special">;</span> <span class="comment">// public data</span>
 <span class="keyword">private</span><span class="special">:</span>
   <span class="special">...</span>
<span class="special">};</span>
</pre>
<p>
          A corresponding Boost.Python extension class can be created with:
        </p>
<pre class="programlisting"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">;</span>

<span class="identifier">class_</span><span class="special">&lt;</span><span class="identifier">Foo</span><span class="special">,</span><span class="identifier">bases</span><span class="special">&lt;</span><span class="identifier">Bar</span><span class="special">,</span><span class="identifier">Baz</span><span class="special">&gt;</span> <span class="special">&gt;(</span><span class="string">"Foo"</span><span class="special">,</span>
          <span class="string">"This is Foo's docstring."</span>
          <span class="string">"It describes our Foo extension class"</span><span class="special">,</span>

          <span class="identifier">init</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">,</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*&gt;(</span><span class="identifier">args</span><span class="special">(</span><span class="string">"x"</span><span class="special">,</span><span class="string">"y"</span><span class="special">),</span> <span class="string">"__init__ docstring"</span><span class="special">)</span>
          <span class="special">)</span>
   <span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="identifier">init</span><span class="special">&lt;</span><span class="keyword">double</span><span class="special">&gt;())</span>
   <span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"get_name"</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">Foo</span><span class="special">::</span><span class="identifier">get_name</span><span class="special">,</span> <span class="identifier">return_internal_reference</span><span class="special">&lt;&gt;())</span>
   <span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"set_name"</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">Foo</span><span class="special">::</span><span class="identifier">set_name</span><span class="special">)</span>
   <span class="special">.</span><span class="identifier">def_readwrite</span><span class="special">(</span><span class="string">"value"</span><span class="special">,</span> <span class="special">&amp;</span><span class="identifier">Foo</span><span class="special">::</span><span class="identifier">value</span><span class="special">);</span>
</pre>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2002-2005, 2015 David Abrahams, Stefan Seefeld<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="concepts/objectwrapper.html"><img src="../images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="../images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../images/home.png" alt="Home"></a><a accesskey="n" href="high_level_components/boost_python_def_hpp.html"><img src="../images/next.png" alt="Next"></a>
</div>
</body>
</html>