.TH "cereal::construct< T >" 3 "Sat Oct 10 2026 08:08:15" "cereal" \" -*- nroff -*- .ad l .nh .SH NAME cereal::construct< T > \- Used to construct types with no default constructor\&. .SH SYNOPSIS .br .PP .PP \fR#include \fP .SS "Public Member Functions" .in +1c .ti -1c .RI "template void \fBoperator()\fP (Args &&\&.\&.\&. args)" .br .RI "Construct and initialize the type T with the given arguments\&. " .ti -1c .RI "T * \fBoperator\->\fP ()" .br .RI "Get a reference to the initialized underlying object\&. " .ti -1c .RI "T * \fBptr\fP ()" .br .RI "Returns a raw pointer to the initialized underlying object\&. " .in -1c .SS "Friends" .in +1c .ti -1c .RI "template struct \fB::cereal::memory_detail::LoadAndConstructLoadWrapper\fP" .br .ti -1c .RI "template struct \fB::cereal::boost_variant_detail::LoadAndConstructLoadWrapper\fP" .br .in -1c .SH "Detailed Description" .PP .SS "template .br class cereal::construct< T >"Used to construct types with no default constructor\&. When serializing a type that has no default constructor, cereal will attempt to call either the class static function load_and_construct or the appropriate template specialization of \fBLoadAndConstruct\fP\&. cereal will pass that function a reference to the archive as well as a reference to a construct object which should be used to perform the allocation once data has been appropriately loaded\&. .PP .PP .nf struct MyType { // note the lack of default constructor MyType( int xx, int yy ); int x, y; double notInConstructor; template void serialize( Archive & ar ) { ar( x, y ); ar( notInConstructor ); } template static void load_and_construct( Archive & ar, cereal::construct & construct ) { int x, y; ar( x, y ); // use construct object to initialize with loaded data construct( x, y ); // access to member variables and functions via \-> operator ar( construct\->notInConstructor ); // could also do the above section by: double z; ar( z ); construct\->notInConstructor = z; } }; .fi .PP .PP \fBTemplate Parameters\fP .RS 4 \fIT\fP The class type being serialized .RE .PP .SH "Member Function Documentation" .PP .SS "template template void \fBcereal::construct\fP< T >::operator() (Args &&\&.\&.\&. args)\fR [inline]\fP" .PP Construct and initialize the type T with the given arguments\&. This will forward all arguments to the underlying type T, calling an appropriate constructor\&. .PP Calling this function more than once will result in an exception being thrown\&. .PP \fBParameters\fP .RS 4 \fIargs\fP The arguments to the constructor for T .RE .PP \fBExceptions\fP .RS 4 \fI\fBException\fP\fP If called more than once .RE .PP .SS "template T * \fBcereal::construct\fP< T >::operator\-> ()\fR [inline]\fP" .PP Get a reference to the initialized underlying object\&. This must be called after the object has been initialized\&. .PP \fBReturns\fP .RS 4 A reference to the initialized object .RE .PP \fBExceptions\fP .RS 4 \fI\fBException\fP\fP If called before initialization .RE .PP .SS "template T * \fBcereal::construct\fP< T >::ptr ()\fR [inline]\fP" .PP Returns a raw pointer to the initialized underlying object\&. This is mainly intended for use with passing an instance of a constructed object to \fBcereal::base_class\fP\&. .PP It is strongly recommended to avoid using this function in any other circumstance\&. .PP \fBReturns\fP .RS 4 A raw pointer to the initialized type .RE .PP .SH "Author" .PP Generated automatically by Doxygen for cereal from the source code\&.