Espaços nominais
Variantes
Acções

std::remove_cv, std::remove_const, std::remove_volatile

Da cppreference.com
< cpp‎ | types

 
 
Biblioteca de utilitários
Digite apoio (basic types, RTTI, type traits)
Gerenciamento de memória dinâmica
De tratamento de erros
Utilidades do programa
Variadic funções
Data e hora
Objetos de função
(C++11)
Os operadores relacionais
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
Pares e tuplas
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
Troque, avançar e avançar
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
(C++11)
 
Apoio a tipos
Tipos básicos
Original:
Basic types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Tipos fundamentais
Tipos inteiros de largura fixos(C++11)
Limites numéricos
Original:
Numeric limits
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
C numérico limita interface
Informações de tipo de tempo de execução
Original:
Runtime type information
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Características de tipo
Original:
Type traits
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Principais categorias de tipo
Original:
Primary type categories
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Propriedades de tipo
Original:
Type properties
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
(C++11)
Operações apoiadas
Original:
Supported operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Relacionamentos e consultas de propriedade
Original:
Relationships and property queries
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
(C++11)
(C++11)
Tipo modificações
Original:
Type modifications
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
remove_cvremove_constremove_volatile
(C++11)(C++11)(C++11)
(C++11)(C++11)(C++11)
Transformações tipo
Original:
Type transformations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
(C++11)
(C++11)
Digite constantes traço
Original:
Type trait constants
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
Definido no cabeçalho <type_traits>
template<class T >
struct remove_cv;
(1) (desde C++11)
template<class T >
struct remove_const;
(2) (desde C++11)
template<class T >
struct remove_volatile;
(3) (desde C++11)

Provides the member typedef type which is the same as T, except that its topmost cv-qualifiers are removed.

1) removes the topmost const, the topmost volatile, or both, if present.

2) removes the topmost const

3) removes the topmost volatile

Índice

[editar]Tipos de membro

Nome
Original:
Name
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Definition
type the type T without cv-qualifier

[editar]Possível implementação

template<class T >struct remove_cv {typedeftypename std::remove_volatile<typename std::remove_const<T>::type>::type type;};   template<class T >struct remove_const {typedef T type;};template<class T >struct remove_const<const T>{typedef T type;};   template<class T >struct remove_volatile {typedef T type;};template<class T >struct remove_volatile<volatile T>{typedef T type;};

[editar]Exemplo

Removing const/volatile from constvolatileint* does not modify the type, because the pointer itself is neither const nor volatile.

#include <iostream>#include <type_traits>   int main(){typedef std::remove_cv<constint>::type type1;typedef std::remove_cv<volatileint>::type type2;typedef std::remove_cv<constvolatileint>::type type3;typedef std::remove_cv<constvolatileint*>::type type4;typedef std::remove_cv<int*constvolatile>::type type5;   std::cout<<"test1 "<<(std::is_same<int, type1>::value?"passed":"failed")<<'\n';std::cout<<"test2 "<<(std::is_same<int, type2>::value?"passed":"failed")<<'\n';std::cout<<"test3 "<<(std::is_same<int, type3>::value?"passed":"failed")<<'\n';std::cout<<"test4 "<<(std::is_same<constvolatileint*, type4>::value?"passed":"failed")<<'\n';std::cout<<"test5 "<<(std::is_same<int*, type5>::value?"passed":"failed")<<'\n';}

Saída:

test1 passed test2 passed test3 passed test4 passed test5 passed

[editar]Veja também

(C++11)
verifica se um tipo é const qualificado
Original:
checks if a type is const-qualified
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(modelo de classe)[edit]
verifica se um tipo é volátil qualificado
Original:
checks if a type is volatile-qualified
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(modelo de classe)[edit]
close