add is_string security
This commit is contained in:
parent
bb49c6f96b
commit
7ec159ac5f
11
bin/main.cpp
11
bin/main.cpp
@ -17,6 +17,7 @@
|
|||||||
#include "utils/utils.hpp"
|
#include "utils/utils.hpp"
|
||||||
#include "security/validate_email.hpp"
|
#include "security/validate_email.hpp"
|
||||||
#include "security/generate_uuid.hpp"
|
#include "security/generate_uuid.hpp"
|
||||||
|
#include "security/is_string.hpp"
|
||||||
|
|
||||||
// for example
|
// for example
|
||||||
int f(int a)
|
int f(int a)
|
||||||
@ -200,4 +201,14 @@ int main(int argc, char *argv[])
|
|||||||
// ec: security::generate_uuid
|
// ec: security::generate_uuid
|
||||||
hack::log()(hack::security::generate_uuid());
|
hack::log()(hack::security::generate_uuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// ec: security::is_string
|
||||||
|
std::string s {"test"};
|
||||||
|
hack::log()(hack::security::is_string<decltype ("test_string")>::value);
|
||||||
|
hack::log()(hack::security::is_string<decltype (s)>::value);
|
||||||
|
hack::log()(hack::security::is_string<decltype (123)>::value);
|
||||||
|
hack::log()(hack::security::is_string<decltype ('c')>::value);
|
||||||
|
hack::log()(hack::security::is_string<decltype ("c")>::value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace hack::range
|
namespace hack::range
|
||||||
{
|
{
|
||||||
|
// являются ли числа максимум и минимум последовательности
|
||||||
template<typename T, typename... Args>
|
template<typename T, typename... Args>
|
||||||
bool within(const T min, const T max, Args... args)
|
bool within(const T min, const T max, Args... args)
|
||||||
{
|
{
|
||||||
|
14
src/security/is_string.hpp
Normal file
14
src/security/is_string.hpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <variant>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
namespace hack::security
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
struct is_string : public std::disjunction<
|
||||||
|
std::is_same<char*, typename std::decay_t<T>>,
|
||||||
|
std::is_same<const char*, typename std::decay_t<T>>,
|
||||||
|
std::is_same<std::string, typename std::decay_t<T>>> {};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user