This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool findMatchingFiles(std::vector<std::string> &files) | |
{ | |
SmallVector<char, 256> currentPath; | |
std::error_code ec; | |
llvm::sys::fs::file_status fileStatus; | |
llvm::sys::fs::current_path(currentPath); | |
for (llvm::sys::fs::recursive_directory_iterator I(currentPath, ec), E; | |
I != E; I.increment(ec)) { | |
if (ec) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <utility> | |
#include <type_traits> | |
auto toString(bool b) | |
{ | |
return b ? "true" : "false"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <type_traits> | |
template <typename T> | |
std::enable_if_t<std::is_convertible_v<T, std::string>, std::string> | |
toString(const T& value) | |
{ | |
return { value }; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::is_same< | |
decltype(std::declval<T>().toString()), | |
std::string | |
>::type; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace details | |
{ | |
template <typename Type> | |
struct HasToString { | |
private: | |
template<typename T> | |
static constexpr auto check(T*) -> typename std::is_same< | |
decltype(std::declval<T>().toString()), | |
std::string | |
>::type; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//big credits to this guy, for a hints: https://stackoverflow.com/a/16824239/4175394 | |
template <typename Type> | |
struct HasToString { | |
private: | |
template<typename T> | |
static constexpr auto check(T*) -> typename std::is_same< | |
decltype(std::declval<T>().toString()), | |
std::string | |
>::type; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> | |
std::enable_if_t<std::is_convertible_v<T, std::string>, std::string> | |
toString(const T& value) | |
{ | |
return { value }; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace details | |
{ | |
template <typename T> | |
constexpr auto canCallStdString = !std::is_same_v<T, bool> && | |
(std::is_integral_v<T> || | |
std::is_unsigned_v<T> || | |
std::is_floating_point_v<T>); | |
} | |
template <typename T> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> | |
std::enable_if_t<!std::is_same_v<T, bool> && | |
(std::is_integral_v<T> || | |
std::is_unsigned_v<T> || | |
std::is_floating_point_v<T>), | |
std::string> | |
toString(const T& value) | |
{ | |
return std::to_string(value); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> | |
std::enable_if_t<std::is_integral_v<T>::value || | |
std::is_unsigned_v<T>::value || | |
std::is_floating_point_v<T>::value, | |
std::string> | |
toString(const T& value) | |
{ | |
return std::to_string(value); | |
} |