add within

This commit is contained in:
chatlanin
2022-03-02 11:08:14 +03:00
parent d7bff82e02
commit 55a2bacc0e
9 changed files with 64 additions and 4 deletions

View File

@@ -1,3 +1,4 @@
inc += include_directories('.')
subdir('string')
subdir('range')

14
src/range/meson.build Normal file
View File

@@ -0,0 +1,14 @@
headers = ['range.hpp']
sources = ['range.cpp']
lib = library(
'range',
include_directories : inc,
install : true,
sources: [headers, sources]
)
range_dep = declare_dependency(
include_directories: inc,
link_with: lib
)

5
src/range/range.cpp Normal file
View File

@@ -0,0 +1,5 @@
#include "range.hpp"
namespace hack
{
}

15
src/range/range.hpp Normal file
View File

@@ -0,0 +1,15 @@
#pragma once
#include <string>
#include <vector>
namespace hack
{
template<typename T, typename... Args>
bool within(T min, T max, Args... args)
{
return ((min <= args && max >= args) && ...);
// 1, 5, 2, 3, 4
// ( (1 <= 2 && 5 >= 2) && (1 <= 3 && 5 >= 3) && (1 <= 4 && 5 >= 4) )
}
}