mirror of
https://github.com/BlackMATov/kari.hpp.git
synced 2025-12-13 04:56:49 +07:00
@@ -2,6 +2,7 @@ version: "{build}"
|
||||
shallow_clone: true
|
||||
image:
|
||||
- Visual Studio 2017
|
||||
- Visual Studio 2019 Preview
|
||||
platform:
|
||||
- Win32
|
||||
- x64
|
||||
|
||||
53
.travis.yml
53
.travis.yml
@@ -1,10 +1,6 @@
|
||||
language: cpp
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
dist: trusty
|
||||
addons: { apt: { sources: ubuntu-toolchain-r-test, packages: ["xorg-dev", "g++-6"] } }
|
||||
env: MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
|
||||
- os: linux
|
||||
dist: trusty
|
||||
addons: { apt: { sources: ubuntu-toolchain-r-test, packages: ["xorg-dev", "g++-7"] } }
|
||||
@@ -13,18 +9,6 @@ matrix:
|
||||
dist: trusty
|
||||
addons: { apt: { sources: ubuntu-toolchain-r-test, packages: ["xorg-dev", "g++-8"] } }
|
||||
env: MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
|
||||
- os: linux
|
||||
dist: trusty
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-precise-3.8"], packages: ["xorg-dev", "clang-3.8", "g++-5"] } }
|
||||
env: MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8"
|
||||
- os: linux
|
||||
dist: trusty
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-precise-3.9"], packages: ["xorg-dev", "clang-3.9", "g++-5"] } }
|
||||
env: MATRIX_EVAL="CC=clang-3.9 && CXX=clang++-3.9"
|
||||
- os: linux
|
||||
dist: trusty
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-trusty-4.0"], packages: ["xorg-dev", "clang-4.0", "g++-5"] } }
|
||||
env: MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0"
|
||||
- os: linux
|
||||
dist: trusty
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-trusty-5.0"], packages: ["xorg-dev", "clang-5.0", "g++-7"] } }
|
||||
@@ -33,24 +17,14 @@ matrix:
|
||||
dist: trusty
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-trusty-6.0"], packages: ["xorg-dev", "clang-6.0", "g++-7"] } }
|
||||
env: MATRIX_EVAL="CC=clang-6.0 && CXX=clang++-6.0"
|
||||
- os: osx
|
||||
osx_image: xcode8.3
|
||||
compiler: clang
|
||||
- os: osx
|
||||
osx_image: xcode9
|
||||
compiler: clang
|
||||
- os: osx
|
||||
osx_image: xcode9.1
|
||||
compiler: clang
|
||||
- os: osx
|
||||
osx_image: xcode9.2
|
||||
compiler: clang
|
||||
- os: osx
|
||||
osx_image: xcode9.3
|
||||
compiler: clang
|
||||
- os: osx
|
||||
osx_image: xcode9.4
|
||||
compiler: clang
|
||||
- os: linux
|
||||
dist: trusty
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-trusty-7"], packages: ["xorg-dev", "clang-7", "g++-7"] } }
|
||||
env: MATRIX_EVAL="CC=clang-7 && CXX=clang++-7"
|
||||
- os: linux
|
||||
dist: trusty
|
||||
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-trusty-8"], packages: ["xorg-dev", "clang-8", "g++-7"] } }
|
||||
env: MATRIX_EVAL="CC=clang-8 && CXX=clang++-8"
|
||||
- os: osx
|
||||
osx_image: xcode10
|
||||
compiler: clang
|
||||
@@ -58,5 +32,16 @@ matrix:
|
||||
after_success: ./scripts/upload_coverage.sh
|
||||
before_install:
|
||||
- eval "${MATRIX_EVAL}"
|
||||
- if [ "$TRAVIS_OS_NAME" == 'osx' ]; then
|
||||
brew update;
|
||||
brew upgrade cmake;
|
||||
brew install git-lfs;
|
||||
fi
|
||||
- if [ "$TRAVIS_OS_NAME" == 'linux' ]; then
|
||||
mkdir $HOME/cmake;
|
||||
export PATH="$HOME/cmake/bin:$PATH";
|
||||
travis_retry wget -q https://cmake.org/files/v3.11/cmake-3.11.4-Linux-x86_64.sh;
|
||||
sh cmake-3.11.4-Linux-x86_64.sh --prefix=$HOME/cmake --exclude-subdir --skip-license;
|
||||
fi
|
||||
script:
|
||||
- ./scripts/build_all.sh
|
||||
|
||||
@@ -1,43 +1,20 @@
|
||||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
|
||||
project(kari)
|
||||
# 3.8 version is required for `cxx_std_17`
|
||||
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
|
||||
|
||||
#
|
||||
# coverage mode
|
||||
#
|
||||
|
||||
option(KARI_BUILD_WITH_COVERAGE "Build with coverage" OFF)
|
||||
if(KARI_BUILD_WITH_COVERAGE AND (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang"))
|
||||
add_definitions(-DKARI_BUILD_WITH_COVERAGE)
|
||||
set(KARI_COVERAGE_FLAGS "--coverage")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${KARI_COVERAGE_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${KARI_COVERAGE_FLAGS}")
|
||||
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} ${KARI_COVERAGE_FLAGS}")
|
||||
if(NOT DEFINED PROJECT_NAME)
|
||||
set(BUILD_AS_STANDALONE ON)
|
||||
endif()
|
||||
|
||||
#
|
||||
# sanitizer mode
|
||||
#
|
||||
project(kari.hpp)
|
||||
|
||||
option(KARI_BUILD_WITH_SANITIZER "Build with sanitizer" OFF)
|
||||
if(KARI_BUILD_WITH_SANITIZER AND (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang"))
|
||||
add_definitions(-DKARI_BUILD_WITH_SANITIZER)
|
||||
set(KARI_SANITIZER_FLAGS "-fno-omit-frame-pointer -fsanitize=address")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${KARI_SANITIZER_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${KARI_SANITIZER_FLAGS}")
|
||||
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} ${KARI_SANITIZER_FLAGS}")
|
||||
add_library(${PROJECT_NAME} INTERFACE)
|
||||
target_include_directories(${PROJECT_NAME} INTERFACE headers)
|
||||
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
|
||||
|
||||
if(BUILD_AS_STANDALONE)
|
||||
option(BUILD_WITH_UNTESTS "Build with unit tests" ON)
|
||||
if(BUILD_WITH_UNTESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(untests)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#
|
||||
# tests executable
|
||||
#
|
||||
|
||||
file(GLOB test_sources "*.cpp" "*.hpp")
|
||||
add_executable(${PROJECT_NAME} ${test_sources})
|
||||
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
CXX_STANDARD 14
|
||||
CXX_STANDARD_REQUIRED YES
|
||||
CXX_EXTENSIONS NO)
|
||||
|
||||
enable_testing()
|
||||
add_test(${PROJECT_NAME} ${PROJECT_NAME})
|
||||
|
||||
28
README.md
28
README.md
@@ -1,42 +1,44 @@
|
||||
# kari.hpp [](https://twitter.com/intent/tweet?text=Experimental%20library%20for%20currying%20in%20C%2B%2B14&url=https://github.com/BlackMATov/kari.hpp&via=BMEngine&hashtags=cpp,currying,cpp14,cpp17,functionalprogramming)
|
||||
# kari.hpp [](https://twitter.com/intent/tweet?text=Experimental%20library%20for%20currying%20in%20C%2B%2B17&url=https://github.com/BlackMATov/kari.hpp&via=BMEngine&hashtags=cpp,currying,cpp17,functionalprogramming)
|
||||
|
||||
> Experimental library for currying in C++14
|
||||
> Experimental library for currying in C++17
|
||||
|
||||
[![travis][badge.travis]][travis]
|
||||
[![appveyor][badge.appveyor]][appveyor]
|
||||
[![codecov][badge.codecov]][codecov]
|
||||
[![language][badge.language]][language]
|
||||
[![license][badge.license]][license]
|
||||
[![godbolt][badge.godbolt]][godbolt]
|
||||
[![wandbox][badge.wandbox]][wandbox]
|
||||
[![paypal][badge.paypal]][paypal]
|
||||
|
||||
[badge.travis]: https://img.shields.io/travis/BlackMATov/kari.hpp/master.svg?logo=travis
|
||||
[badge.appveyor]: https://img.shields.io/appveyor/ci/BlackMATov/kari-hpp/master.svg?logo=appveyor
|
||||
[badge.codecov]: https://img.shields.io/codecov/c/github/BlackMATov/kari.hpp/master.svg?logo=codecov
|
||||
[badge.language]: https://img.shields.io/badge/language-C%2B%2B14-red.svg
|
||||
[badge.language]: https://img.shields.io/badge/language-C%2B%2B17-yellow.svg
|
||||
[badge.license]: https://img.shields.io/badge/license-MIT-blue.svg
|
||||
[badge.godbolt]: https://img.shields.io/badge/try%20it-on%20godbolt-orange.svg
|
||||
[badge.wandbox]: https://img.shields.io/badge/try%20it-on%20wandbox-5cb85c.svg
|
||||
[badge.paypal]: https://img.shields.io/badge/donate-PayPal-orange.svg?logo=paypal&colorA=00457C
|
||||
|
||||
[travis]: https://travis-ci.org/BlackMATov/kari.hpp
|
||||
[appveyor]: https://ci.appveyor.com/project/BlackMATov/kari-hpp
|
||||
[codecov]: https://codecov.io/gh/BlackMATov/kari.hpp
|
||||
[language]: https://en.wikipedia.org/wiki/C%2B%2B14
|
||||
[language]: https://en.wikipedia.org/wiki/C%2B%2B17
|
||||
[license]: https://github.com/BlackMATov/kari.hpp/blob/master/LICENSE.md
|
||||
[godbolt]: https://godbolt.org/g/XPBgjY
|
||||
[wandbox]: https://wandbox.org/permlink/F6AVvcCHsoBztZ0w
|
||||
[paypal]: https://www.paypal.me/matov
|
||||
|
||||
[kari]: https://github.com/BlackMATov/kari.hpp
|
||||
|
||||
## Installation
|
||||
|
||||
[kari.hpp][kari] is a single header library. All you need to do is copy the header file into your project and include this file:
|
||||
[kari.hpp][kari] is a header-only library. All you need to do is copy the headers files from `headers` directory into your project and include them:
|
||||
|
||||
|
||||
```cpp
|
||||
#include "kari.hpp"
|
||||
#include "kari_hpp/kari.hpp"
|
||||
```
|
||||
|
||||
Also, you can add the root repository directory to your [cmake](https://cmake.org) project:
|
||||
|
||||
```cmake
|
||||
add_subdirectory(external/kari.hpp)
|
||||
target_link_libraries(your_project_target kari.hpp)
|
||||
```
|
||||
|
||||
## Examples
|
||||
@@ -129,7 +131,7 @@ namespace kari {
|
||||
struct is_curried;
|
||||
|
||||
template < typename F >
|
||||
constexpr bool is_curried_v = is_curried<F>::value;
|
||||
inline constexpr bool is_curried_v = is_curried<F>::value;
|
||||
|
||||
template < std::size_t N, typename F, typename... Args >
|
||||
struct curry_t {
|
||||
|
||||
@@ -12,254 +12,6 @@
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// https://github.com/BlackMATov/invoke.hpp
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define INVOKE_HPP_NOEXCEPT_RETURN(...) \
|
||||
noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
|
||||
|
||||
#define INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN(...) \
|
||||
noexcept(noexcept(__VA_ARGS__)) -> decltype (__VA_ARGS__) { return __VA_ARGS__; }
|
||||
|
||||
//
|
||||
// void_t
|
||||
//
|
||||
|
||||
namespace invoke_hpp
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
template < typename... Args >
|
||||
struct make_void {
|
||||
using type = void;
|
||||
};
|
||||
}
|
||||
|
||||
template < typename... Args >
|
||||
using void_t = typename impl::make_void<Args...>::type;
|
||||
}
|
||||
|
||||
//
|
||||
// is_reference_wrapper
|
||||
//
|
||||
|
||||
namespace invoke_hpp
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
template < typename T >
|
||||
struct is_reference_wrapper_impl
|
||||
: std::false_type {};
|
||||
|
||||
template < typename U >
|
||||
struct is_reference_wrapper_impl<std::reference_wrapper<U>>
|
||||
: std::true_type {};
|
||||
}
|
||||
|
||||
template < typename T >
|
||||
struct is_reference_wrapper
|
||||
: impl::is_reference_wrapper_impl<std::remove_cv_t<T>> {};
|
||||
}
|
||||
|
||||
//
|
||||
// invoke
|
||||
//
|
||||
|
||||
namespace invoke_hpp
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
//
|
||||
// invoke_member_object_impl
|
||||
//
|
||||
|
||||
template
|
||||
<
|
||||
typename Base, typename F, typename Derived,
|
||||
typename std::enable_if_t<std::is_base_of<Base, std::decay_t<Derived>>::value, int> = 0
|
||||
>
|
||||
constexpr auto invoke_member_object_impl(F Base::* f, Derived&& ref)
|
||||
INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN(
|
||||
std::forward<Derived>(ref).*f)
|
||||
|
||||
template
|
||||
<
|
||||
typename Base, typename F, typename RefWrap,
|
||||
typename std::enable_if_t<is_reference_wrapper<std::decay_t<RefWrap>>::value, int> = 0
|
||||
>
|
||||
constexpr auto invoke_member_object_impl(F Base::* f, RefWrap&& ref)
|
||||
INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN(
|
||||
ref.get().*f)
|
||||
|
||||
template
|
||||
<
|
||||
typename Base, typename F, typename Pointer,
|
||||
typename std::enable_if_t<
|
||||
!std::is_base_of<Base, std::decay_t<Pointer>>::value &&
|
||||
!is_reference_wrapper<std::decay_t<Pointer>>::value
|
||||
, int> = 0
|
||||
>
|
||||
constexpr auto invoke_member_object_impl(F Base::* f, Pointer&& ptr)
|
||||
INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN(
|
||||
(*std::forward<Pointer>(ptr)).*f)
|
||||
|
||||
//
|
||||
// invoke_member_function_impl
|
||||
//
|
||||
|
||||
template
|
||||
<
|
||||
typename Base, typename F, typename Derived, typename... Args,
|
||||
typename std::enable_if_t<std::is_base_of<Base, std::decay_t<Derived>>::value, int> = 0
|
||||
>
|
||||
constexpr auto invoke_member_function_impl(F Base::* f, Derived&& ref, Args&&... args)
|
||||
INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN(
|
||||
(std::forward<Derived>(ref).*f)(std::forward<Args>(args)...))
|
||||
|
||||
template
|
||||
<
|
||||
typename Base, typename F, typename RefWrap, typename... Args,
|
||||
typename std::enable_if_t<is_reference_wrapper<std::decay_t<RefWrap>>::value, int> = 0
|
||||
>
|
||||
constexpr auto invoke_member_function_impl(F Base::* f, RefWrap&& ref, Args&&... args)
|
||||
INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN(
|
||||
(ref.get().*f)(std::forward<Args>(args)...))
|
||||
|
||||
template
|
||||
<
|
||||
typename Base, typename F, typename Pointer, typename... Args,
|
||||
typename std::enable_if_t<
|
||||
!std::is_base_of<Base, std::decay_t<Pointer>>::value &&
|
||||
!is_reference_wrapper<std::decay_t<Pointer>>::value
|
||||
, int> = 0
|
||||
>
|
||||
constexpr auto invoke_member_function_impl(F Base::* f, Pointer&& ptr, Args&&... args)
|
||||
INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN(
|
||||
((*std::forward<Pointer>(ptr)).*f)(std::forward<Args>(args)...))
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
typename F, typename... Args,
|
||||
typename std::enable_if_t<!std::is_member_pointer<std::decay_t<F>>::value, int> = 0
|
||||
>
|
||||
constexpr auto invoke(F&& f, Args&&... args)
|
||||
INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN(
|
||||
std::forward<F>(f)(std::forward<Args>(args)...))
|
||||
|
||||
template
|
||||
<
|
||||
typename F, typename T,
|
||||
typename std::enable_if_t<std::is_member_object_pointer<std::decay_t<F>>::value, int> = 0
|
||||
>
|
||||
constexpr auto invoke(F&& f, T&& t)
|
||||
INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN(
|
||||
impl::invoke_member_object_impl(std::forward<F>(f), std::forward<T>(t)))
|
||||
|
||||
template
|
||||
<
|
||||
typename F, typename... Args,
|
||||
typename std::enable_if_t<std::is_member_function_pointer<std::decay_t<F>>::value, int> = 0
|
||||
>
|
||||
constexpr auto invoke(F&& f, Args&&... args)
|
||||
INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN(
|
||||
impl::invoke_member_function_impl(std::forward<F>(f), std::forward<Args>(args)...))
|
||||
}
|
||||
|
||||
//
|
||||
// invoke_result
|
||||
//
|
||||
|
||||
namespace invoke_hpp
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
struct invoke_result_impl_tag {};
|
||||
|
||||
template < typename Void, typename F, typename... Args >
|
||||
struct invoke_result_impl {};
|
||||
|
||||
template < typename F, typename... Args >
|
||||
struct invoke_result_impl<void_t<invoke_result_impl_tag, decltype(invoke_hpp::invoke(std::declval<F>(), std::declval<Args>()...))>, F, Args...> {
|
||||
using type = decltype(invoke_hpp::invoke(std::declval<F>(), std::declval<Args>()...));
|
||||
};
|
||||
}
|
||||
|
||||
template < typename F, typename... Args >
|
||||
struct invoke_result
|
||||
: impl::invoke_result_impl<void, F, Args...> {};
|
||||
|
||||
template < typename F, typename... Args >
|
||||
using invoke_result_t = typename invoke_result<F, Args...>::type;
|
||||
}
|
||||
|
||||
//
|
||||
// is_invocable
|
||||
//
|
||||
|
||||
namespace invoke_hpp
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
struct is_invocable_r_impl_tag {};
|
||||
|
||||
template < typename Void, typename R, typename F, typename... Args >
|
||||
struct is_invocable_r_impl
|
||||
: std::false_type {};
|
||||
|
||||
template < typename R, typename F, typename... Args >
|
||||
struct is_invocable_r_impl<void_t<is_invocable_r_impl_tag, invoke_result_t<F, Args...>>, R, F, Args...>
|
||||
: std::conditional_t<
|
||||
std::is_void<R>::value,
|
||||
std::true_type,
|
||||
std::is_convertible<invoke_result_t<F, Args...>, R>> {};
|
||||
}
|
||||
|
||||
template < typename R, typename F, typename... Args >
|
||||
struct is_invocable_r
|
||||
: impl::is_invocable_r_impl<void, R, F, Args...> {};
|
||||
|
||||
template < typename F, typename... Args >
|
||||
using is_invocable = is_invocable_r<void, F, Args...>;
|
||||
}
|
||||
|
||||
//
|
||||
// apply
|
||||
//
|
||||
|
||||
namespace invoke_hpp
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
template < typename F, typename Tuple, std::size_t... I >
|
||||
constexpr decltype(auto) apply_impl(F&& f, Tuple&& args, std::index_sequence<I...>)
|
||||
INVOKE_HPP_NOEXCEPT_RETURN(
|
||||
invoke_hpp::invoke(
|
||||
std::forward<F>(f),
|
||||
std::get<I>(std::forward<Tuple>(args))...))
|
||||
}
|
||||
|
||||
template < typename F, typename Tuple >
|
||||
constexpr decltype(auto) apply(F&& f, Tuple&& args)
|
||||
INVOKE_HPP_NOEXCEPT_RETURN(
|
||||
impl::apply_impl(
|
||||
std::forward<F>(f),
|
||||
std::forward<Tuple>(args),
|
||||
std::make_index_sequence<std::tuple_size<std::decay_t<Tuple>>::value>()))
|
||||
}
|
||||
|
||||
#undef INVOKE_HPP_NOEXCEPT_RETURN
|
||||
#undef INVOKE_HPP_NOEXCEPT_DECLTYPE_RETURN
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// https://github.com/BlackMATov/kari.hpp
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define KARI_HPP_NOEXCEPT_RETURN(...) \
|
||||
noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
|
||||
|
||||
@@ -278,19 +30,19 @@ namespace kari
|
||||
std::size_t N, typename F, typename... Args,
|
||||
typename std::enable_if_t<
|
||||
(N == 0) &&
|
||||
invoke_hpp::is_invocable<std::decay_t<F>, Args...>::value
|
||||
std::is_invocable_v<std::decay_t<F>, Args...>
|
||||
, int> = 0
|
||||
>
|
||||
constexpr auto make_curry(F&& f, std::tuple<Args...>&& args)
|
||||
KARI_HPP_NOEXCEPT_RETURN(
|
||||
invoke_hpp::apply(std::forward<F>(f), std::move(args)))
|
||||
std::apply(std::forward<F>(f), std::move(args)))
|
||||
|
||||
template
|
||||
<
|
||||
std::size_t N, typename F, typename... Args,
|
||||
typename std::enable_if_t<
|
||||
(N > 0) ||
|
||||
!invoke_hpp::is_invocable<std::decay_t<F>, Args...>::value
|
||||
!std::is_invocable_v<std::decay_t<F>, Args...>
|
||||
, int> = 0
|
||||
>
|
||||
constexpr auto make_curry(F&& f, std::tuple<Args...>&& args)
|
||||
@@ -408,7 +160,7 @@ namespace kari
|
||||
: detail::is_curried_impl<std::remove_cv_t<F>> {};
|
||||
|
||||
template < typename F >
|
||||
constexpr bool is_curried_v = is_curried<F>::value;
|
||||
inline constexpr bool is_curried_v = is_curried<F>::value;
|
||||
|
||||
//
|
||||
// curry
|
||||
@@ -512,7 +264,7 @@ namespace kari
|
||||
KARI_HPP_NOEXCEPT_DECLTYPE_RETURN(
|
||||
std::forward<A>(a))
|
||||
};
|
||||
constexpr auto fid = curry(fid_t{});
|
||||
inline constexpr auto fid = curry(fid_t{});
|
||||
|
||||
//
|
||||
// fconst
|
||||
@@ -524,7 +276,7 @@ namespace kari
|
||||
KARI_HPP_NOEXCEPT_DECLTYPE_RETURN(
|
||||
std::forward<A>(a))
|
||||
};
|
||||
constexpr auto fconst = curry(fconst_t{});
|
||||
inline constexpr auto fconst = curry(fconst_t{});
|
||||
|
||||
//
|
||||
// fflip
|
||||
@@ -539,7 +291,7 @@ namespace kari
|
||||
std::forward<B>(b),
|
||||
std::forward<A>(a)))
|
||||
};
|
||||
constexpr auto fflip = curry(fflip_t{});
|
||||
inline constexpr auto fflip = curry(fflip_t{});
|
||||
|
||||
//
|
||||
// fpipe
|
||||
@@ -555,7 +307,7 @@ namespace kari
|
||||
std::forward<G>(g),
|
||||
std::forward<A>(a))))
|
||||
};
|
||||
constexpr auto fpipe = curry(fpipe_t{});
|
||||
inline constexpr auto fpipe = curry(fpipe_t{});
|
||||
|
||||
//
|
||||
// fcompose
|
||||
@@ -571,7 +323,7 @@ namespace kari
|
||||
std::forward<F>(f),
|
||||
std::forward<A>(a))))
|
||||
};
|
||||
constexpr auto fcompose = curry(fcompose_t{});
|
||||
inline constexpr auto fcompose = curry(fcompose_t{});
|
||||
|
||||
//
|
||||
// fpipe operators
|
||||
@@ -651,7 +403,7 @@ namespace kari
|
||||
namespace underscore
|
||||
{
|
||||
struct us_t {};
|
||||
constexpr us_t _{};
|
||||
inline constexpr us_t _{};
|
||||
|
||||
//
|
||||
// is_underscore, is_underscore_v
|
||||
@@ -659,10 +411,10 @@ namespace kari
|
||||
|
||||
template < typename T >
|
||||
struct is_underscore
|
||||
: std::integral_constant<bool, std::is_same<us_t, std::remove_cv_t<T>>::value> {};
|
||||
: std::bool_constant<std::is_same_v<us_t, std::remove_cv_t<T>>> {};
|
||||
|
||||
template < typename T >
|
||||
constexpr bool is_underscore_v = is_underscore<T>::value;
|
||||
inline constexpr bool is_underscore_v = is_underscore<T>::value;
|
||||
|
||||
//
|
||||
// unary operators
|
||||
@@ -4,7 +4,7 @@ set -e
|
||||
BUILD_DIR=`dirname "$BASH_SOURCE"`/../build
|
||||
mkdir -p $BUILD_DIR/coverage
|
||||
cd $BUILD_DIR/coverage
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug -DKARI_BUILD_WITH_COVERAGE=ON ../..
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_WITH_COVERAGE=ON ../..
|
||||
cmake --build . -- -j8
|
||||
|
||||
lcov -d . -z
|
||||
|
||||
32
untests/CMakeLists.txt
Normal file
32
untests/CMakeLists.txt
Normal file
@@ -0,0 +1,32 @@
|
||||
# 3.11 version is required for `FetchContent`
|
||||
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
|
||||
|
||||
project(kari.hpp.untests)
|
||||
|
||||
set(CATCH_BUILD_TESTING OFF CACHE BOOL "" FORCE)
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
catch2
|
||||
GIT_REPOSITORY https://github.com/catchorg/catch2)
|
||||
|
||||
FetchContent_GetProperties(catch2)
|
||||
if(NOT catch2_POPULATED)
|
||||
FetchContent_Populate(catch2)
|
||||
add_subdirectory(${catch2_SOURCE_DIR} ${catch2_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
option(BUILD_WITH_COVERAGE "Build with coverage" OFF)
|
||||
if(BUILD_WITH_COVERAGE AND (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang"))
|
||||
set(COVERAGE_FLAGS "--coverage")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
|
||||
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} ${COVERAGE_FLAGS}")
|
||||
endif()
|
||||
|
||||
file(GLOB UNTESTS_SOURCES "*.cpp" "*.hpp")
|
||||
add_executable(${PROJECT_NAME} ${UNTESTS_SOURCES})
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
Catch2
|
||||
kari.hpp)
|
||||
add_test(${PROJECT_NAME} ${PROJECT_NAME})
|
||||
@@ -1,9 +1,9 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/BlackMATov/kari.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2018 Matvey Cherevko
|
||||
* Copyright (C) 2017-2019, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#define CATCH_CONFIG_FAST_COMPILE
|
||||
#include "catch.hpp"
|
||||
#include <catch2/catch.hpp>
|
||||
@@ -5,9 +5,9 @@
|
||||
******************************************************************************/
|
||||
|
||||
#define CATCH_CONFIG_FAST_COMPILE
|
||||
#include "catch.hpp"
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include "kari.hpp"
|
||||
#include <kari_hpp/kari.hpp>
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
Reference in New Issue
Block a user