C++ features by examples
Template argument deduction
Collaboration diagram for Template argument deduction:

Classes

struct  template_struct< T >
 template with type float by default More...
 

Functions

constexpr pair deducted_pair (1, 2.3)
 pair<int, double> p(1, 2.3); More...
 
constexpr tuple deducted_tuple (4, 2, 2.5)
 auto t = make_tuple(4, 3, 2.5); More...
 
deque deduction_guide1_queue (int_vector.begin(), int_vector.end())
 deduction_guides More...
 
vector deduction_guide1_vector (int_vector.begin(), int_vector.end())
 deduced vector<int> More...
 

Variables

template_struct template_arg_deduction {1}
 deducted <int> More...
 
vector< int > int_vector = {1, 2, 3, 4}
 
deque deduction_guide2_queue {int_vector.cbegin(), int_vector.cend()}
 deduced deque<vector<int> :: iterator> More...
 
array deduction_guide_array {1, 2, 3, 4}
 deduction_guides More...
 
vector deduction_guide2_vector {int_vector.begin(), int_vector.end()}
 deduced vector<vector<int> :: iterator> More...
 

Detailed Description

template_argument_deduction

class_template_argument_deduction

Function Documentation

◆ deducted_pair()

constexpr pair deducted_pair ( ,
2.  3 
)
constexpr

pair<int, double> p(1, 2.3);

◆ deducted_tuple()

constexpr tuple deducted_tuple ( ,
,
2.  5 
)
constexpr

auto t = make_tuple(4, 3, 2.5);

◆ deduction_guide1_queue()

deque deduction_guide1_queue ( int_vector.  begin(),
int_vector.  end() 
)

deduction_guides

deduced deque<int>

Here is the caller graph for this function:

◆ deduction_guide1_vector()

vector deduction_guide1_vector ( int_vector.  begin(),
int_vector.  end() 
)

deduced vector<int>

deduction_guides

Here is the caller graph for this function:

Variable Documentation

◆ deduction_guide2_queue

deque deduction_guide2_queue {int_vector.cbegin(), int_vector.cend()}

deduced deque<vector<int> :: iterator>

Definition at line 73 of file 17.cpp.

◆ deduction_guide2_vector

vector deduction_guide2_vector {int_vector.begin(), int_vector.end()}

deduced vector<vector<int> :: iterator>

Definition at line 82 of file 17.cpp.

◆ deduction_guide_array

array deduction_guide_array {1, 2, 3, 4}

deduction_guides

Definition at line 76 of file 17.cpp.

◆ int_vector

vector<int> int_vector = {1, 2, 3, 4}

Definition at line 65 of file 17.cpp.

◆ template_arg_deduction

template_struct template_arg_deduction {1}

deducted <int>

Definition at line 56 of file 17.cpp.