Support Class Library
A set of tools providing classes and utility
extend.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifdef SCL_USE_IOSTREAM_EXTEND
4 #include <string>
5 #include <utility>
6 #include <scl/macros.h>
11 #include <scl/utils/toString.h>
12 
13 namespace std{
20  template <class T, class = META::void_t<META::enable_if_t<
21  !META::defines_std_to_string<T>()
22  && META::defines_scl_to_string<T>()
23  >>>
24  std::string to_string(T&& obj){
25  return asString(std::forward<T>(obj));
26  }
27 }
28 
29 namespace scl{
30  namespace utils{
35  template <class T>
36  struct ToString<T, META::enable_if_t<
37  !META::defines_scl_to_string<T>()
38  && META::defines_std_to_string<T>()
39  >>{
40  std::string operator()(T& obj) const{
41  return std::to_string(obj);
42  }
43  };
44  }
45 }
46 
47 //The following will add the definitions
48 #include "toString.h"
49 #endif
50 
51 //Note: to enable these operators, you must be in/use the namespace scl::tools::iostream
void void_t
The must have.
Definition: void_t.h:10
Global namespace of the SCL.
Definition: alias.hpp:3
#define META
Definition: macros.h:8
STL namespace.
#define asString
Definition: macros.h:9
typename std::enable_if< B, T >::type enable_if_t
An handy type alias for the result of std::enable_if.
Definition: enable_if.h:12