fork(1) download
  1. #include <string>
  2.  
  3. template<typename CharT>
  4. class Format
  5. {
  6. public:
  7. typedef std::basic_string<CharT> StringT;
  8.  
  9. template< typename CharT>
  10. friend Format<CharT> format(const std::basic_string<CharT>& str,std::size_t n);
  11.  
  12. template< typename CharT>
  13. friend Format<CharT> format(const CharT* str,std::size_t n);
  14.  
  15. private:
  16. Format(const StringT& str, std::size_t firstArgNumber=0){};
  17. Format(const Format& f){};
  18. Format& operator==(const Format& f){};
  19. };
  20. //----------------------- friend format() -----------------------------------------
  21. template< typename CharT>
  22. Format<CharT> format(const std::basic_string<CharT>& str,std::size_t n=0)
  23. {
  24. return Format<CharT>(str,n);
  25. }
  26. //---------------------------------------------------------------------------------
  27. template< typename CharT>
  28. Format<CharT> format(const CharT* c_str,std::size_t n=0)
  29. {
  30. return Format<CharT>(c_str,n);
  31. }
  32. //---------------------------------------------------------------------------------
  33.  
  34. int main()
  35. {
  36. using namespace std;
  37.  
  38. format("some");
  39.  
  40. return 0;
  41. }
  42.  
  43.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:9:13: error: declaration of 'class CharT'
   template< typename CharT>
             ^
prog.cpp:3:10: error:  shadows template parm 'class CharT'
 template<typename CharT>
          ^
prog.cpp:12:13: error: declaration of 'class CharT'
   template< typename CharT>
             ^
prog.cpp:3:10: error:  shadows template parm 'class CharT'
 template<typename CharT>
          ^
stdout
Standard output is empty