@@ -435,6 +435,22 @@ struct move_only_function_base
435435 {
436436 }
437437
438+ template <class VT , class ...CArgs>
439+ void init_object ( std::false_type /* use_sbo */ , CArgs&& ...args )
440+ {
441+ s_.pobj_ = new VT ( std::forward<CArgs>( args )... );
442+ invoke_ = &mo_invoke_object_holder<RQ, Const, NoEx, VT, R, Args...>::invoke_object;
443+ manager_ = &manage_object<VT>;
444+ }
445+
446+ template <class VT , class ...CArgs>
447+ void init_object ( std::true_type /* use_sbo */ , CArgs&& ...args )
448+ {
449+ new ( s_.addr () ) VT ( std::forward<CArgs>( args )... );
450+ invoke_ = &mo_invoke_local_holder<RQ, Const, NoEx, VT, R, Args...>::invoke_local;
451+ manager_ = &manage_local<VT>;
452+ }
453+
438454 template <class VT , class ...CArgs>
439455 void init ( std::false_type /* is_function */ , CArgs&& ...args )
440456 {
@@ -444,18 +460,7 @@ struct move_only_function_base
444460 return ;
445461 }
446462
447- if ( !storage::use_sbo<VT>() )
448- {
449- s_.pobj_ = new VT ( std::forward<CArgs>( args )... );
450- invoke_ = &mo_invoke_object_holder<RQ, Const, NoEx, VT, R, Args...>::invoke_object;
451- manager_ = &manage_object<VT>;
452- }
453- else
454- {
455- new ( s_.addr () ) VT ( std::forward<CArgs>( args )... );
456- invoke_ = &mo_invoke_local_holder<RQ, Const, NoEx, VT, R, Args...>::invoke_local;
457- manager_ = &manage_local<VT>;
458- }
463+ init_object<VT>( std::integral_constant<bool , storage::use_sbo<VT>()>{}, std::forward<CArgs>( args )... );
459464 }
460465
461466 template <class VT , class ...CArgs>
0 commit comments