std::remove_extent - cppreference.com
Da cppreference.com.
|
|
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
<metanoindex/>
<tbody> </tbody>
| Elemento definito nell'header <type_traits> |
||
|
|
(dal C++11) | |
Se T è un array di qualche X tipo, fornisce l'elemento di typedef type pari a X, altrimenti type è T. Si noti che se T è una matrice multidimensionale, solo la prima dimensione è stato rimosso.
Original:
If T is an array of some type X, provides the member typedef type equal to X, otherwise type is T. Note that if T is a multidimensional array, only the first dimension is removed.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Membri tipi
Nome Original: Name The text has been machine-translated via Google Translate. |
Definition |
type
|
il tipo dell'elemento di Original: the type of the element of The text has been machine-translated via Google Translate. |
Possibile implementazione
template<class T> struct remove_extent { typedef T type; }; template<class T> struct remove_extent<T[]> { typedef T type; }; template<class T, std::size_t N> struct remove_extent<T[N]> { typedef T type;};
Esempio
#include <iostream> #include <iterator> #include <algorithm> #include <type_traits> template<class A> typename std::enable_if< std::rank<A>::value == 1 >::type print_1d(const A& a) { copy(a, a+std::extent<A>::value, std::ostream_iterator<typename std::remove_extent<A>::type>(std::cout, " ")); std::cout << '\n'; } int main() { int a[][3] = {{1,2,3},{4,5,6}}; // print_1d(a); // compile-time error print_1d(a[1]); }
Output:
Vedi anche
(C++11) |
Verifica se un tipo è un tipo di matrice Original: checks if a type is an array type The text has been machine-translated via Google Translate. (classe template) [modifica] |
(C++11) |
ottiene il numero di dimensioni di un tipo di matrice Original: obtains the number of dimensions of an array type The text has been machine-translated via Google Translate. (classe template) [modifica] |
(C++11) |
ottiene la dimensione di un tipo di matrice lungo una dimensione specificata Original: obtains the size of an array type along a specified dimension The text has been machine-translated via Google Translate. (classe template) [modifica] |
(C++11) |
removes all extents from the given array type (classe template) [modifica] |