BINDERS(3)
π Binder Classes(3) π
okay bestie, this is the Binder Classes(3) page from the Library Functions Manual, and it's literally all about those old-school binder functors. Let's get into it π
β¨
πΈ NAME πΈ
Binder Classes -
β¨ Classes β¨
class std::binder1st< _Operation >β One of the binder functors. πclass std::binder2nd< _Operation >β One of the binder functors. π
β¨ Functions β¨
template<typename _Operation , typename _Tp > binder1st< _Operation >βstd::bind1st (const _Operation &__fn, const _Tp &__x)template<typename _Operation , typename _Tp > binder2nd< _Operation >βstd::bind2nd (const _Operation &__fn, const _Tp &__x)
β¨ Variables β¨
struct std::auto_ptr_ref std::_GLIBCXX_DEPRECATED_ATTR
π Detailed Description π
Binders turn functions/functors with two arguments into functors with a single argument, storing an argument to be applied later. For example, a variable B of type binder1st is constructed from a functor f and an argument x. Later, B's operator() is called with a single argument y. The return value is the value of f(x,y). B can be 'called' with various arguments (y1, y2, ...) and will in turn call f(x,y1), f(x,y2), ... β¨
The function bind1st is provided to save some typing. It takes the function and an argument as parameters, and returns an instance of binder1st. π«Ά
The type binder2nd and its creator function bind2nd do the same thing, but the stored argument is passed as the second parameter instead of the first, e.g., bind2nd(std::minus<float>,1.3) will create a functor whose operator() accepts a floating-point number, subtracts 1.3 from it, and returns the result. (If bind1st had been used, the functor would perform '1.3 - x' instead.) π
Creator-wrapper functions like bind1st are intended to be used in calling algorithms. Their return values will be temporary objects. (The goal is to not require you to type names like std::binder1st<std::plus<int>> for declaring a variable to hold the return value from bind1st(std::plus<int>,5).) π
These become more useful when combined with the composition functions. π
π Function Documentation π
π« template<typename _Operation , typename _Tp > binder1st<_Operation>
std::bind1st (const _Operation & __fn, const _Tp & __x) [inline]
One of the binder functors.
Definition at line 124 of file binders.h.
π« template<typename _Operation , typename _Tp > binder2nd<_Operation>
std::bind2nd (const _Operation & __fn, const _Tp & __x) [inline]
One of the binder functors.
Definition at line 159 of file binders.h.
π Variable Documentation π
std::binder2nd std::_GLIBCXX_DEPRECATED_ATTR
A simple smart pointer providing strict ownership semantics.
One of the binder functors.
A wrapper class to provide auto_ptr with reference semantics. For example, an auto_ptr can be assigned (or constructed from) the result of a function which returns an auto_ptr by value.
All the auto_ptr_ref stuff should happen behind the scenes. π
The Standard says:
An auto_ptr owns the object it holds a pointer to. Copying an auto_ptr copies the pointer and transfers ownership to the destination. If more than one auto_ptr owns the same object at the same time the behavior of the program is undefined. The uses of auto_ptr include providing temporary exception-safety for dynamically allocated memory, passing ownership of dynamically allocated memory to a function, and returning dynamically allocated memory from a function. auto_ptr does not meet the CopyConstructible and Assignable requirements for Standard Library container elements and thus instantiating a Standard Library container with an auto_ptr results in undefined behavior.
Quoted from [20.4.5]/3.
Good examples of what can and cannot be done with auto_ptr can be found in the libstdc++ testsuite. π§
_GLIBCXX_RESOLVE_LIB_DEFECTS 127. auto_ptr<> conversion issues These resolutions have all been incorporated. π
π«Ά Author π«Ά
Generated automatically by Doxygen for libstdc++ from the source code.
xoxo bestie, that's the whole vibe: libstdc++, dated 21 Apr 2009, from the Binder Classes(3) page. π
β¨
π¦ where this page comes from
- nixpkgs unstable: std-man-pages 4.4.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms