The Wayback Machine - https://web.archive.org/web/20241123231634/https://www.geeksforgeeks.org/is_rvalue_reference-template-in-cpp/
Open In App

is_rvalue_reference Template in C++

Last Updated : 19 Nov, 2018
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The std::is_rvalue_reference template of C++ STL is used to check whether the type is a rvalue reference type or not. It returns a boolean value showing the same.

Syntax:

template <class T > struct is_rvalue_reference;

Parameters: This template accepts a single parameter T (Trait class) to check whether T is a rvalue reference type.

Return Value: This template returns a boolean value as shown below:

  • True: if the type is a rvalue_reference type.
  • False: if the type is a non-rvalue_reference type.

Below programs illustrate the std::is_lvalue_reference template in C++ STL:

Program 1:




// C++ program to illustrate
// std::is_rvalue_reference template
  
#include <iostream>
#include <type_traits>
using namespace std;
  
// main program
  
class gfg {
};
  
int main()
{
    cout << std::boolalpha;
    cout << "is_rvalue_reference: "
         << '\n';
    cout << "gfg: "
         << is_rvalue_reference<gfg>::value
         << '\n';
    cout << "gfg&: "
         << is_rvalue_reference<gfg&>::value
         << '\n';
    cout << "gfg&&: "
         << is_rvalue_reference<gfg&&>::value
         << '\n';
  
    return 0;
}


Output:

is_rvalue_reference: 
gfg: false
gfg&: false
gfg&&: true

Program 2:




// C++ program to illustrate
// std::is_rvalue_reference template
  
#include <iostream>
#include <type_traits>
using namespace std;
  
// main program
int main()
{
  
    cout << std::boolalpha;
    cout << "is_rvalue_reference: "
         << '\n';
    cout << "int: "
         << is_rvalue_reference<int>::value
         << '\n';
    cout << "int&: "
         << is_rvalue_reference<int&>::value
         << '\n';
    cout << "int&&: "
         << is_rvalue_reference<int&&>::value
         << '\n';
    cout << "char: "
         << is_rvalue_reference<char>::value
         << '\n';
    cout << "char&: "
         << is_rvalue_reference<char&>::value
         << '\n';
    cout << "char&&: "
         << is_rvalue_reference<char&&>::value
         << '\n';
  
    return 0;
}


Output:

is_rvalue_reference: 
int: false
int&: false
int&&: true
char: false
char&: false
char&&: true

Program 3:




// C++ program to illustrate
// std::is_rvalue_reference template
  
#include <iostream>
#include <type_traits>
using namespace std;
  
// main program
int main()
{
    cout << std::boolalpha;
    cout << "is_rvalue_reference: "
         << '\n';
    cout << "float: "
         << is_rvalue_reference<float>::value
         << '\n';
    cout << "float&: "
         << is_rvalue_reference<float&>::value
         << '\n';
    cout << "float&&: "
         << is_rvalue_reference<float&&>::value
         << '\n';
    cout << "double: "
         << is_rvalue_reference<double>::value
         << '\n';
    cout << "double&: "
         << is_rvalue_reference<double&>::value
         << '\n';
    cout << "double&&: "
         << is_rvalue_reference<double&&>::value
         << '\n';
  
    return 0;
}


Output:

is_rvalue_reference: 
float: false
float&: false
float&&: true
double: false
double&: false
double&&: true


Previous Article
Next Article

Similar Reads

is_fundamental Template in C++
The is_fundamental template of C++ STL is used to check whether the type is a fundamental type or not. It returns a boolean value showing the same. Syntax: template <class T> struct is_fundamental; Parameter: This template accepts a single parameter T (Trait class) to check whether T is a fundamental type or not. Return Value: This template r
2 min read
is_pointer Template in C++
The std::is_pointer template of C++ STL is used to check whether the given type is pointer or not. It returns a boolean value showing the same. Syntax: template <class T > struct is_pointer; Parameter: This template accepts a single parameter T (Trait class) to check whether T is a pointer or not. Return Value: This template returns a boolean
2 min read
generate_canonical Function template in C++
This template in C++ is used to convert the value generated by g into a floating point value in the range [0, 1) preserving the uniformity properties of sequences generated with g. To generate enough entropy generate_canonical() will call g() exactly 'k' times where, [Tex] k = max(1, \lceil \frac{b}{log_2 R} \rceil)[/Tex] Syntax: template ( class R
2 min read
std is_union() template in C++
The std::is_union template of C++ STL is used to check whether the given type is union or not. It returns a boolean value showing the same. Syntax: template <class T> struct is_union; Parameter: This template accepts single parameter T (Trait class) to check whether T is a union or not. Return Value: This template returns a boolean value as s
2 min read
is_class template in C++
The std::is_class template of C++ STL is used to check whether the given type is class or not. It returns a boolean value showing the same. Syntax: template <class T> struct is_class; Parameter: This template accepts single parameter T (Trait class) to check whether T is a class or not. Return Value: This template returns a boolean value as s
2 min read
std::is_enum Template in C++
The std::is_enum template of C++ STL is used to check whether the given type is enum or not. It returns a boolean value showing the same. Syntax: template <class T> struct is_enum; Parameter: This template accepts single parameter T (Trait class) to check whether T is a enumeration type or not. Return Value: This template returns a boolean va
2 min read
std::is_integral template in C++
The std::is_integral template of C++ STL is used to check whether the given type is integral or not. It returns a boolean value showing the same. Syntax: template <class T> struct is_integral; Template Parameter: This template accepts a single parameter T (Trait class) to check whether T is a integral type or not. Return Value: This template
2 min read
std is_floating_point Template in C++
The std::is_floating_point template of C++ STL is used to check whether the given type is a floating point value or not. It returns a boolean value showing the same. Syntax: template < class T > struct is_floating_point; Parameter: This template accepts a single parameter T (Trait class) to check whether T is a floating point type. Return Val
2 min read
std is_object Template in C++
The std::is_object template of C++ STL is used to check whether the given type is object or not. It returns a boolean value showing the same. Syntax: template <class T > struct is_object; Parameter: This template accepts a single parameter T (Trait class) to check whether T is a object type or not. Return Value: This template returns a boolea
2 min read
is_arithmetic Template in C++
The std::is_arithmetic templateof C++ STL is used to check whether the given type is arithmetic or not. An Arithmetic type means an integral type or a floating-point type. It returns a boolean value showing the same. Syntax: template <class T> struct is_arithmetic; Parameters: This template accepts a single parameter T (Trait class) to check
3 min read
is_lvalue_reference Template in C++
The std::is_lvalue_reference template of C++ STL is used to check whether the type is a lvalue reference type or not. It returns a boolean value showing the same. Syntax: template <class T > struct is_lvalue_reference; Template Parameter: This template accepts a single parameter T (Trait class) to check whether T is a lvalue reference type or
2 min read
is_reference Template in C++
The std::is_reference template of C++ STL is used to check whether the type is a reference type or not. It returns a boolean value showing the same. Syntax: template <class T > struct is_reference; Parameter: This template accepts a single parameter T (Trait class) to check whether T is a reference type or not. Return Value:This template retu
2 min read
is_scalar template in C++
The std::is_scalar template of C++ STL is used to check whether the given type is a scalar type or not. It returns a boolean value showing the same. Syntax: template < class T > struct is_scalar; Parameter: This template accepts a single parameter T (Trait class) to check whether T is a scalar type or not. Return Value: This template returns
2 min read
std::is_compound Template in C++
The std::is_compound template of C++ STL is used to check the whether the type is a compound type or not. It returns a boolean value showing the same. Syntax: template < class T > struct is_compound; Parameter: This template contains single parameter T (Trait class) to check whether T is a compound type or not. Return Value: This template ret
2 min read
is_const Template in C++
The std::is_const template of C++ STL is used to check whether the type is a const-qualified or not. It returns a boolean value showing the same. Syntax: template < class T >struct is_const; Template Parameter: This template contains single parameter T (Trait class) to check whether T is a const-qualified type. Return Value: This template ret
2 min read
is_void template in C++
The std::is_void template of C++ STL is used to check whether the type is a void or not. It returns a boolean value showing the same. Syntax: template < class T > struct is_void; Parameter: This template contains single parameter T (Trait class) to check whether T is a void type or not. Return Value: This template returns a boolean value as s
2 min read
is_volatile template in C++
The std::is_volatile template of C++ STL is used to check whether the type is a volatile-qualified or not. It returns a boolean value showing the same. Syntax: template < class T > struct is_volatile; Parameter: This template contains single parameter T (Trait class) to check whether T is a volatile-qualified type or not. Return Value: This t
2 min read
is_final template in C++14
The std::is_final template of C++ STL is used to check whether the type is a final or not. Syntax: template < class T > struct is_final; Parameter: This template contains single parameter T (Trait class) to check whether T is a final type. Return Value: This template returns a boolean value as shown below: True: if the type is a final. False:
2 min read
is_signed template in C++
The std::is_signed template of C++ STL is used to check whether the type is a signed arithmetic type or not. Syntax: template <class T > struct is_signed; Parameters: This template contains single parameter T (Trait class) to check whether T is a signed arithmetic type or not. Return Value: This template returns a boolean value as shown below
2 min read
is_unsigned template in C++
The std::is_unsigned template of C++ STL is used to check whether the type is a unsigned arithmetic type or not. It returns a boolean value showing the same. Syntax: template <class T > struct is_unsigned; Parameters: This template contains single parameter T (Trait class) to check whether T is a unsigned arithmetic type or not. Return Value:
2 min read
is_pod template in C++
The std::is_pod template of C++ STL is used to check whether the type is a plain-old data(POD) type or not. It returns a boolean value showing the same. Syntax: template < class T > struct is_pod; Parameter: This template contains single parameter T (Trait class) to check whether T is a pod type or not. Return Value: This template returns a b
2 min read
is_abstract template in C++
The std::is_abstract template of C++ STL is used to check whether the type is a abstract class type or not. It returns a boolean value showing the same. Syntax: template < class T > struct is_abstract; Parameter: This template contains single parameter T (Trait class) to check whether T is a abstract class type or not. Return Value: This temp
2 min read
is_polymorphic template in C++
The std::is_polymorphic template of C++ STL is used to checks whether the type is a polymorphic class type or not. It returns a boolean value showing the same. Syntax: template < class T > struct is_polymorphic; Parameter: This template contains single parameter T (Trait class) to check whether T is a polymorphic class type or not. Return Val
2 min read
is_standard_layout template in C++
The std::is_standard_layout template of C++ STL is used to check whether the type is a standard layout or not. It returns a boolean value showing the same. Syntax: template < class T > struct is_standard_layout; Parameters: This template contains single parameter T (Trait class) to check whether T is a standard layout type or not. Return Valu
3 min read
is_empty template in C++
The std::is_empty template of C++ STL is used to check whether the given type is empty or not. This method returns a boolean value showing whether the given type is empty or not. Syntax: template < class T > struct is_empty; Parameters: This template contains single parameter T (Trait class) that identifies whether T is a empty type. Return V
2 min read
std::extent() template in C++ with Examples
The std::is_const template of C++ STL is present in the <type_traits> header file. If A is an array that has a rank greater than B, the extent is the bound of the Ath dimension and if B is zero and A is the array of unknown bound, than the extent value is zero. Header File: #include<type_traits> Syntax: template <class A, unsigned B
2 min read
std::is_assignable template in C++ with Examples
The std::is_assignable template of C++ STL is present in the <type_traits> header file. The std::is_assignable template of C++ STL is used to check whether a value of B type can be assigned to a A. It returns the boolean value either true or false. Below is the syntax for the same: Header File: #include<type_traits> Syntax: template
2 min read
std::is_function template in C++ with Examples
The std::is_function of C++ STL is used to check whether the given type T is function or not. It returns the boolean value either true or false. Below is the syntax for the same: Header File: #include<type_traits> Syntax: template <class T> struct is_function; Parameter: The template std::is_function accepts a single parameter T (Trait
2 min read
type_traits::alignment_of template in C++
It is used to find the member constant value equal to the alignment requirement of the type T. If T is a reference type than it returns the alignment requirements of the type referred to. If T is an array type than it returns the alignment requirements of the element type.Header File: #include<type_traits> Syntax: template <class T> str
1 min read
std::is_convertible template in C++ with Examples
The std::is_convertible template of C++ STL is present in the <type_traits> header file. The std::is_convertible template of C++ STL is used to check whether any data type A is implicitly convertible to any data type B. It returns the boolean value either true or false. Header File: #include<type_traits> Template Class: template< cla
2 min read
Practice Tags :
three90RightbarBannerImg