add within
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
inc += include_directories('.')
|
||||
|
||||
subdir('string')
|
||||
subdir('range')
|
||||
|
||||
14
src/range/meson.build
Normal file
14
src/range/meson.build
Normal 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
5
src/range/range.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#include "range.hpp"
|
||||
|
||||
namespace hack
|
||||
{
|
||||
}
|
||||
15
src/range/range.hpp
Normal file
15
src/range/range.hpp
Normal 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) )
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user