Skip to content
Zome edited this page Dec 3, 2021 · 1 revision

is_integral

Brief

Struct that holds a boolean value. True for the following types: bool, char, int, short int, long int, long int, long long int, unsigned int, unsigned short int, unsigned long int, unsigned long long int, char, signed char, unsigned char and wchar_t. False for anything else.

Usage

bool ft::is_integral<type_to_check>::value

enable_if

Brief

Enables a type if a given condition is met. Otherwise, it won’t compile.

Usage

typename ft::enable_if< !ft::is_integral<InputIterator>::value, InputIterator>::type* = nullptr i don’t really understand this

pair

Brief

Provides a way to store two heterogeneous objects as a single unit.

Usage

std::pair <std::string,double> product ("tomatoes",2.30);
product.first = "shoes";                  // the type of first is string
product.second = 39.90;                   // the type of second is double
std::cout << "The price of " << product1.first << " is $" << product1.second << '\n';

Make pair

Brief

Automatically detects types and constructs a pair.

Usage

bar = std::make_pair (10.5,'A');

Reference

Equal

Brief

ft::equal(first1, last1, first2) Checks if every element iterating from first1 to last1 is equal to the elements iterating from first2

Usage

bool is_palindrome(const std::string& s) { return ft::equal(s.begin(), s.begin() + s.size()/2, s.rbegin()); }

Lexicographical compare

Brief

Performs lexicographical comparison (like the dictionaries) between two ranges of iterators.

Usage

char foo[]="Apple";
char bar[]="apartment";
std::cout << std::lexicographical_compare(foo,foo+5,bar,bar+9);