From 7ec159ac5f983cc2b1d81dc6627ec4bb72d9e3a1 Mon Sep 17 00:00:00 2001 From: chatlanin Date: Wed, 29 Jun 2022 12:36:48 +0300 Subject: [PATCH] add is_string security --- bin/main.cpp | 11 +++++++++++ src/range/range.hpp | 1 + src/security/is_string.hpp | 14 ++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 src/security/is_string.hpp diff --git a/bin/main.cpp b/bin/main.cpp index c3d2dbb..ace7fc2 100644 --- a/bin/main.cpp +++ b/bin/main.cpp @@ -17,6 +17,7 @@ #include "utils/utils.hpp" #include "security/validate_email.hpp" #include "security/generate_uuid.hpp" +#include "security/is_string.hpp" // for example int f(int a) @@ -200,4 +201,14 @@ int main(int argc, char *argv[]) // ec: security::generate_uuid hack::log()(hack::security::generate_uuid()); } + + { + // ec: security::is_string + std::string s {"test"}; + hack::log()(hack::security::is_string::value); + hack::log()(hack::security::is_string::value); + hack::log()(hack::security::is_string::value); + hack::log()(hack::security::is_string::value); + hack::log()(hack::security::is_string::value); + } } diff --git a/src/range/range.hpp b/src/range/range.hpp index 662a2b1..5ef9e4c 100644 --- a/src/range/range.hpp +++ b/src/range/range.hpp @@ -2,6 +2,7 @@ namespace hack::range { + // являются ли числа максимум и минимум последовательности template bool within(const T min, const T max, Args... args) { diff --git a/src/security/is_string.hpp b/src/security/is_string.hpp new file mode 100644 index 0000000..713f397 --- /dev/null +++ b/src/security/is_string.hpp @@ -0,0 +1,14 @@ +#pragma once + +#include +#include +#include + +namespace hack::security +{ + template + struct is_string : public std::disjunction< + std::is_same>, + std::is_same>, + std::is_same>> {}; +}