Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    [C++] Passare una string-literal come parametro di una class template

    Come si può fare una cosa del genere?

    codice:
    template <const char *str>
    class foo { /*...*/ };
    
    
    // Questo ovviamente non deve funzionare...
    foo <"string literal"> x;
    
    
    // Ma questo dovrebbe, eppure il compilatore da errore
    char str[] = "string literal";
    foo <str> y;

    Come posso risolvere? Grazie.
    Fracty - The Fractal Generator



    If you cannot choose a concise name that expresses what the method does, it is possible that your method is attempting to perform too many diverse tasks.

  2. #2
    Utente di HTML.it L'avatar di shodan
    Registrato dal
    Jun 2001
    Messaggi
    2,381
    Leggi qui:
    http://www.eptacom.net/pubblicazioni/pub_it/nl_10.html

    Riguarda le eccezioni, ma spiega anche come fare quello che ti serve.
    This code and information is provided "as is" without warranty of any kind, either expressed
    or implied, including but not limited to the implied warranties of merchantability and/or
    fitness for a particular purpose.

  3. #3
    Grazie, problema risolto.
    Fracty - The Fractal Generator



    If you cannot choose a concise name that expresses what the method does, it is possible that your method is attempting to perform too many diverse tasks.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.