Serialize C++ functor
问题 Can you save the function body of a C++ lambda/functor? For example, say you have light0->lightFunction = []( real tEl, real pAz ) -> Vector { return Vector( // red is up lobe std::max<real>( 0., 5*cos(tEl)-4 ), // green lower lobe std::max<real>( 0., -4*sin(tEl-PI)*cos(pAz-2.5)-3), 0. ) ; } ; And you want to save the function body, so you can load it later (instead of always having to hard code it). Can you do it? 回答1: This lambda doesn't have state (not a closure), so it's an ordinary