mirror of
https://github.com/boostorg/hof.git
synced 2026-01-31 20:22:11 +00:00
Add doc for infix
This commit is contained in:
@@ -14,6 +14,7 @@ extract fuse
|
||||
extract identity
|
||||
extract implicit
|
||||
extract indirect
|
||||
extract infix
|
||||
extract invoke
|
||||
extract is_callable
|
||||
extract lambda
|
||||
|
||||
40
doc/src/infix.md
Normal file
40
doc/src/infix.md
Normal file
@@ -0,0 +1,40 @@
|
||||
infix
|
||||
=====
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
The `infix` function adaptor allows the function to be used as an infix
|
||||
operator. The operator must be placed inside the angle brackets(ie `<`
|
||||
and `>`).
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
template<class F>
|
||||
constexpr infix_adaptor<F> infix(F f);
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
F must be:
|
||||
|
||||
BinaryFunctionObject
|
||||
MoveConstructible
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
struct plus_f
|
||||
{
|
||||
template<class T, class U>
|
||||
T operator()(T x, U y) const
|
||||
{
|
||||
return x+y;
|
||||
}
|
||||
};
|
||||
|
||||
constexpr infix_adaptor<plus_f> plus = {};
|
||||
int r = 3 <plus> 2;
|
||||
assert(r, 5);
|
||||
|
||||
Reference in New Issue
Block a user