Skip to content

Commit b119eed

Browse files
committed
Initial
0 parents  commit b119eed

28 files changed

+262
-0
lines changed

.clang-format

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.cppsm/.clang-format

.cppsm

Submodule .cppsm added at ea2cd9a

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.cppsm/.gitignore

.gitmodules

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule ".cppsm"]
2+
path = .cppsm
3+
url = https://github.com/cppsm/cppsm-boilerplate.git
4+
branch = master

.prettierrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.cppsm/.prettierrc

.travis.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
language: cpp
2+
3+
notifications:
4+
email: false
5+
6+
matrix:
7+
include:
8+
- os: linux
9+
dist: trusty
10+
addons:
11+
apt:
12+
sources:
13+
- ubuntu-toolchain-r-test
14+
- llvm-toolchain-trusty-7
15+
packages:
16+
- g++-8
17+
- clang-7
18+
- os: osx
19+
osx_image: xcode10.2
20+
- os: windows
21+
22+
git:
23+
submodules: false
24+
25+
before_install:
26+
- git submodule update --init
27+
28+
script:
29+
- .cppsm/travis-ci || ./test

CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cmake_minimum_required(VERSION 3.9)
2+
include(.cppsm/c++17-no-rtti-no-exns.cmake)

LICENSE.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Copyright © 2019 Vesa Karvonen
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7+
the Software, and to permit persons to whom the Software is furnished to do so,
8+
subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

NOTES.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Apparently VC++ 2017 is not quite ready for
2+
3+
```c++
4+
template <auto v> struct value_t {
5+
using eval = value_t;
6+
using type = decltype(v);
7+
static constexpr auto value = v;
8+
};
9+
```
10+
11+
because `decltype(v)` does not always seem to give the expected type.

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# [](#contents) [Lax.C++](#) [![Build Status](https://travis-ci.org/per-framework/lax.cpp.svg?branch=v1)](https://travis-ci.org/per-framework/lax.cpp)
2+
3+
Non-strict template metaprogramming primitives for C++.

internals/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
add_conventional_executable_test(lax_test)
2+
target_link_libraries(lax_test PRIVATE lax_v1)
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "lax_v1/comparison.hpp"
2+
#include "lax_v1/logical.hpp"
3+
#include "lax_v1/type.hpp"
4+
#include "lax_v1/type_traits.hpp"
5+
#include "lax_v1/value.hpp"
6+
7+
#include <type_traits>
8+
9+
namespace lax = lax_v1;
10+
11+
static_assert(std::is_same_v<lax::value_t<bool, true>::type, bool>);
12+
13+
static_assert(std::is_same_v<lax::value_t<char, 'x'>::type, char>);
14+
static_assert(std::is_same_v<lax::value_t<short, 101>::type, short>);
15+
static_assert(std::is_same_v<lax::value_t<int, 101>::type, int>);
16+
static_assert(std::is_same_v<lax::value_t<unsigned, 101u>::type, unsigned>);
17+
static_assert(std::is_same_v<lax::value_t<long, 101l>::type, long>);
18+
static_assert(
19+
std::is_same_v<lax::value_t<unsigned long, 101ul>::type, unsigned long>);
20+
static_assert(std::is_same_v<lax::value_t<unsigned long long, 101ull>::type,
21+
unsigned long long>);
22+
23+
static_assert(lax::value_of_v<lax::is_array_m<lax::type_t<int[2]>>>);
24+
25+
int main() { return 0; }

provides/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_conventional_library(lax_v1)
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
#include "lax_v1/comparison_synopsis.hpp"
4+
#include "lax_v1/value.hpp"
5+
6+
template <class LhsExpr, class RhsExpr>
7+
struct lax_v1::lte_m
8+
: value_t<bool, (value_of_v<LhsExpr> <= value_of_v<RhsExpr>)> {};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
3+
namespace lax_v1 {
4+
5+
template <class LhsExpr, class RhsExpr> struct lte_m;
6+
7+
}

provides/include/lax_v1/config.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#pragma once
2+
3+
namespace lax_v1 {}

provides/include/lax_v1/force.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#pragma once
2+
3+
#include "lax_v1/force_synopsis.hpp"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
3+
namespace lax_v1 {
4+
5+
template <class Expr> using force_t = typename Expr::eval;
6+
7+
}

provides/include/lax_v1/lazify.hpp

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
3+
#include "lax_v1/lazify_synopsis.hpp"
4+
#include "lax_v1/type.hpp"
5+
#include "lax_v1/value.hpp"
6+
7+
template <template <class... Parameters> class Function, class... Arguments>
8+
struct lax_v1::lazify_t
9+
: type_t<typename Function<type_of_t<Arguments>...>::type> {};
10+
11+
template <class Type, template <class... Parameters> class Function,
12+
class... Arguments>
13+
struct lax_v1::lazify_v
14+
: value_t<Type, Function<type_of_t<Arguments>...>::value> {};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#pragma once
2+
3+
namespace lax_v1 {
4+
5+
template <template <class... Parameters> class Function, class... Arguments>
6+
struct lazify_t;
7+
8+
template <class Type, template <class... Parameters> class Function,
9+
class... Arguments>
10+
struct lazify_v;
11+
12+
} // namespace lax_v1

provides/include/lax_v1/logical.hpp

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#pragma once
2+
3+
#include "lax_v1/force.hpp"
4+
#include "lax_v1/logical_synopsis.hpp"
5+
#include "lax_v1/value.hpp"
6+
7+
template <class... Exprs> struct lax_v1::and_m : true_t {};
8+
template <class... Exprs>
9+
struct lax_v1::and_m<lax_v1::false_t, Exprs...> : false_t {};
10+
template <class... Exprs>
11+
struct lax_v1::and_m<lax_v1::true_t, Exprs...> : and_m<Exprs...> {};
12+
template <class Expr, class... Exprs>
13+
struct lax_v1::and_m<Expr, Exprs...> : and_m<force_t<Expr>, Exprs...> {};
14+
15+
template <class... Exprs> struct lax_v1::or_m : false_t {};
16+
template <class... Exprs>
17+
struct lax_v1::or_m<lax_v1::true_t, Exprs...> : true_t {};
18+
template <class... Exprs>
19+
struct lax_v1::or_m<lax_v1::false_t, Exprs...> : or_m<Exprs...> {};
20+
template <class Expr, class... Exprs>
21+
struct lax_v1::or_m<Expr, Exprs...> : lax_v1::or_m<force_t<Expr>, Exprs...> {};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
namespace lax_v1 {
4+
5+
template <class... Exprs> struct and_m;
6+
7+
template <class... Exprs> struct or_m;
8+
9+
} // namespace lax_v1

provides/include/lax_v1/type.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#pragma once
2+
3+
#include "lax_v1/type_synopsis.hpp"
4+
5+
template <class T> struct lax_v1::type_t {
6+
using eval = type_t;
7+
using type = T;
8+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#pragma once
2+
3+
namespace lax_v1 {
4+
5+
template <class T> struct type_t;
6+
7+
template <class Expr> using type_of_t = typename Expr::eval::type;
8+
9+
} // namespace lax_v1
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#pragma once
2+
3+
#include "lax_v1/lazify.hpp"
4+
#include "lax_v1/type_traits_synopsis.hpp"
5+
6+
#include <cstddef>
7+
#include <type_traits>
8+
9+
template <class T>
10+
struct lax_v1::alignment_of_m : lazify_v<size_t, std::alignment_of, T> {};
11+
12+
template <class T>
13+
struct lax_v1::is_array_m : lazify_v<bool, std::is_array, T> {};
14+
15+
template <class T>
16+
struct lax_v1::is_pointer_m : lazify_v<bool, std::is_pointer, T> {};
17+
18+
template <class T>
19+
struct lax_v1::remove_all_extents_m : lazify_t<std::remove_all_extents, T> {};
20+
21+
template <class T>
22+
struct lax_v1::remove_pointer_m : lazify_t<std::remove_pointer, T> {};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#pragma once
2+
3+
namespace lax_v1 {
4+
5+
template <class T> struct alignment_of_m;
6+
7+
template <class T> struct is_array_m;
8+
9+
template <class T> struct is_pointer_m;
10+
11+
template <class T> struct remove_all_extents_m;
12+
13+
template <class T> struct remove_pointer_m;
14+
15+
} // namespace lax_v1

provides/include/lax_v1/value.hpp

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#pragma once
2+
3+
#include "lax_v1/type.hpp"
4+
#include "lax_v1/value_synopsis.hpp"
5+
6+
template <class Type, Type value_> struct lax_v1::value_t {
7+
using eval = value_t;
8+
using type = Type;
9+
static constexpr Type value = value_;
10+
};
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#pragma once
2+
3+
#include "lax_v1/type_synopsis.hpp"
4+
5+
namespace lax_v1 {
6+
7+
template <class Type, Type value> struct value_t;
8+
9+
template <class Expr>
10+
inline constexpr type_of_t<Expr> value_of_v = Expr::eval::value;
11+
12+
using true_t = value_t<bool, true>;
13+
using false_t = value_t<bool, false>;
14+
15+
} // namespace lax_v1

0 commit comments

Comments
 (0)