Namespaces
Variants

cpp/utility/functional/function ref/operator=: Difference between revisions

From cppreference.com
Andreas Krug (talk | contribs)
m fmt
Space Mission (talk | contribs)
m Add links to expos-only mems and extend "See also".
 
Line 11: Line 11:
{{dcl end}}
{{dcl end}}


@1@ Copy assignment operator is explicitly-defaulted. {{tt|std::function_ref}} satisfies {{lconcept|copyable}} and {{named req|TriviallyCopyable}}. This defaulted assignment operator performs a shallow copy of the stored {{tti|thunk-ptr}} and {{tti|bound-entity}}.
@1@ Copy assignment operator is explicitly-defaulted. {{tt|std::function_ref}} satisfies {{lconcept|copyable}} and {{named req|TriviallyCopyable}}. This defaulted assignment operator performs a shallow copy of the stored {{|thunk-ptr}} and {{|bound-entity}}.


@2@ User-defined assignment operator is explicitly-deleted if {{c|T}} is not the same type as {{tt|std::function_ref}}, {{c|std::is_pointer_v<T>}} is {{c|false}}, and {{c|T}} is not a specialization of {{lc|std::nontype_t}}. This overload participates in overload resolution only if the constraints are satisfied in the conditions above.
@2@ User-defined assignment operator is explicitly-deleted if {{c|T}} is not the same type as {{tt|std::function_ref}}, {{c|std::is_pointer_v<T>}} is {{c|false}}, and {{c|T}} is not a specialization of {{lc|std::nontype_t}}. This overload participates in overload resolution only if the constraints are satisfied in the conditions above.
Line 21: Line 21:
{{dsc begin}}
{{dsc begin}}
{{dsc inc|cpp/utility/functional/function_ref/dsc constructor}}
{{dsc inc|cpp/utility/functional/function_ref/dsc constructor}}
{{dsc inc|cpp/utility/functional/function/dsc operator{{=}}}}
{{dsc inc|cpp/utility/functional/function/dsc operator{{=}}}}
{{dsc begin}}
{{dsc begin}}


{{langlinks|de|es|fr|it|ja|pt|ru|zh}}
{{langlinks|de|es|fr|it|ja|pt|ru|zh}}

Latest revision as of 12:47, 26 November 2024

 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
 
Function objects
Function invocation
(C++17)(C++23)
Identity function object
(C++20)
Transparent operator wrappers
(C++14)
(C++14)
(C++14)
(C++14)  
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)

Old binders and adaptors
(until C++17*)
(until C++17*)
(until C++17*)
(until C++17*)  
(until C++17*)
(until C++17*)(until C++17*)(until C++17*)(until C++17*)
(until C++20*)
(until C++20*)
(until C++17*)(until C++17*)
(until C++17*)(until C++17*)

(until C++17*)
(until C++17*)(until C++17*)(until C++17*)(until C++17*)
(until C++20*)
(until C++20*)
 
 
constexpr function_ref& operator=( const function_ref& ) noexcept = default;
(1) (since C++26)
template< class T > 
constexpr function_ref& operator=( T ) = delete;
(2) (since C++26)
1) Copy assignment operator is explicitly-defaulted. std::function_ref satisfies copyable and TriviallyCopyable. This defaulted assignment operator performs a shallow copy of the stored thunk-ptr and bound-entity.
2) User-defined assignment operator is explicitly-deleted if T is not the same type as std::function_ref, std::is_pointer_v<T> is false, and T is not a specialization of std::nontype_t. This overload participates in overload resolution only if the constraints are satisfied in the conditions above.

Return value

*this

See also

constructs a new function_ref object
(public member function) [edit]
replaces or destroys the target
(public member function of std::copyable_function) [edit]
assigns a new target
(public member function of std::function<R(Args...)>) [edit]
replaces or destroys the target
(public member function of std::move_only_function) [edit]