| Last change
 on this file since 3e91c6f9 was             9feb34b, checked in by Andrew Beach <ajbeach@…>, 3 years ago | 
        
          | 
Moved toString and toCString to a new header. Updated includes. cassert was somehow getting instances of toString before but that stopped working so I embedded the new smaller include.
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            879 bytes | 
      
      
| Line |  | 
|---|
| 1 | // | 
|---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo | 
|---|
| 3 | // | 
|---|
| 4 | // The contents of this file are covered under the licence agreement in the | 
|---|
| 5 | // file "LICENCE" distributed with Cforall. | 
|---|
| 6 | // | 
|---|
| 7 | // ToString.hpp -- Tools to convert to string. | 
|---|
| 8 | // | 
|---|
| 9 | // Author           : Andrew Beach | 
|---|
| 10 | // Created On       : Tue Mar 28  9:24:00 2023 | 
|---|
| 11 | // Last Modified By : Andrew Beach | 
|---|
| 12 | // Last Modified On : Tue Mar 28  9:24:00 2023 | 
|---|
| 13 | // Update Count     : 0 | 
|---|
| 14 | // | 
|---|
| 15 |  | 
|---|
| 16 | #pragma once | 
|---|
| 17 |  | 
|---|
| 18 | #include <string> | 
|---|
| 19 | #include <sstream> | 
|---|
| 20 |  | 
|---|
| 21 | /// Convert all arguments to strings and concatenate them. | 
|---|
| 22 | template<typename... Params> | 
|---|
| 23 | std::string toString( const Params &... params ) { | 
|---|
| 24 | std::ostringstream buffer; | 
|---|
| 25 | (buffer << ... << params); | 
|---|
| 26 | return buffer.str(); | 
|---|
| 27 | } | 
|---|
| 28 |  | 
|---|
| 29 | /// Convert all arguments to a C-string. | 
|---|
| 30 | /// It is a macro so that a underlying std::string manages the memory. | 
|---|
| 31 | #define toCString( ... ) toString( __VA_ARGS__ ).c_str() | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.