The meanings and simple uses of C + + terms and their English translation (eight)

Source: Internet
Author: User

(1) back_inserter This is an iterator adapter that takes a reference to a container, generates an insert iterator, and when we assign a value through this iterator, the assignment operator calls Push_back to add an element with the given value to the container.

For example: Vector<int> VEC; Empty vector

Auto it = Back_inserter (VEC); Inserting an iterator to an IT assignment adds the element to the VEC

*it = 42; The VEC now has an element with a value of 42

(2) bidirectional iterator (bidirectional iterator): Supports all operations of the forward iterator and has the ability to reverse-move in the sequence.

(3) Two-yuan predicate (binary predicate) a predicate that accepts two arguments. A predicate is a callable expression whose return result is a value that can be used as a condition.

(4) The BIND standard library function , which considers bind as a common function adapter, accepts a callable object and generates a new callable object to "fit" the parameter list of the original object. Bind binds one or more parameters to a callable expression. Bind is defined in the header file functional.

The general form of calling Bindde is:

Auto newcallable = bind (callable, arg_list);

Where newcallable itself is a callable object, Arg_list is a comma-delimited list of arguments that correspond to the parameters of a given callable. That is, when we call Newcallable, Newcallable calls callable and passes it to the arguments in its arg_list. The parameters in the arg_list may contain names such as _n, where n is an integer. These parameters are placeholders, which represent newcallable parameters that occupy the "position" of the arguments passed to newcallable. The value n represents the location where the parameters in the callable object are generated: _1 is the first parameter of newcallable, _2 is the second argument, and so on.

(5) lambda expressions (lambda expression): callable unit of code. A lambda resembles an unnamed inline function. A lambda starts with a capture list that allows lambda to access variables in the function in which it resides. Like a function, Lambda has a (possibly empty) argument list, a return type, and a function body. The lambda can ignore the return type. If the function body is a single return statement, the return type is inferred from the type of the returned object. Otherwise, the ignored return type defaults to void.

A lambda must use the tail return to specify the return type, in the general form:

[Capture list] (parameter list), Rerurn type {function Body }

Where we can ignore the parameter list and return type, but must always contain the capture list and the body of the function.

Auto F = [] {return;};  In this example, we define a callable object F, which does not accept arguments, and returns 42//LAMBDA in the same way as a normal function, using the call Operator: Cout<<f () <<endl;       Printing 42
(6) The callable object (callable . Object) can appear on the left side of the calling operator. The objects of functions, function pointers, lambda expressions, and classes that overload the function call operator are callable objects.

(7) cref/ref the standard library function , returns a copy of the object that holds a reference to a const object of the non-copied type. It is also defined in the header file functional.

(8) Front_inserter iterator adapter , given a container, generates a Push_front insert iterator that adds elements to the beginning of the container.

(9) Type-independent algorithm of the generic algorithm (generic algorithm) .

(10) A forward iterator (forward iterator) can read and write elements, but does not have to support an iterator.

(11) an iterator to an input iterator that can read but not write elements in the sequence is iterator.

(12) Insert an iterator (insert iterator) iterator adapter that generates an iterator that uses the container action to add elements to a given container.

(13) The Insert (Inserter) iterator adapter, which accepts an iterator and a reference to the container, generates an insert iterator that inserts an element at the position before the element pointed to by the given iterator.

(14) Move the iterator (move iterator) iterator adapter, generating an iterator that moves instead of copying the element.

(istream_iterator) a stream iterator that reads the input stream.

For example: Here is an example of using Istream_iterator to read data from a standard input into a vector:

Istream_iterator<int> In_iter (CIN);     Read intistream_iterator<int> EOF from CIN;      IStream post-tail iterator while (in_iter! = EOF)              ////When data is available for reading {      //Post increment operation reads the stream, returns the old value of the iterator      //dereference iterator, obtains the previous value      read from the stream Vec.push_back (*in_iter++);
You can change the program to the following form, using a pair of iterators that represent the range of elements to construct the VEC.

Istream_iterator<int> in_iter,eof; Read Intvector<int> VEC (In_iter, EOF) from CIN;  Constructing VEC from the scope of an iterator
(ostream_iterator) an iterator that writes the output stream.

(17) The random-access iterator (random-access iterator) supports the use of bidirectional iterators, plus the relational operators, subscript operators, and arithmetic operations on iterators that compare iterator values, thus supporting random access elements.

(18) A reverse iterator (reverse iterator) moves the iterator backwards in the sequence. These iterators exchange the meanings of + + and--.

(19) A stream iterator (IStream iterator) can be bound to an iterator to a stream.

(20) A unary predicate (unary predicate) a predicate that accepts a parameter. A predicate is a callable expression whose return result is a value that can be used as a condition.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The meanings and simple uses of C + + terms and their English translation (eight)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.