Skip to content

Commit

Permalink
Merge pull request #20 from LoliGothick/develop
Browse files Browse the repository at this point in the history
Major update
  • Loading branch information
loliGothicK authored Feb 26, 2020
2 parents d91bb80 + b09c2b4 commit 05f6cf8
Show file tree
Hide file tree
Showing 535 changed files with 1,639 additions and 4,488 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
- checkout
- run: apt upgrade -y && apt update -y && apt install -y git
- run: git submodule sync && git submodule update --init --recursive --remote
- run: chmod +x ./mitama_build.sh
- run: ./mitama_build.sh
- run: mkdir -p build && cd build && cmake .. && make -j5 && ctest 2>&1 | tee ./ctset.log


workflows:
build:
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ set(CMAKE_CXX_STANDARD 17) # ...C++17
set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...
set(CMAKE_CXX_EXTENSIONS OFF) #...without compiler extensions like gnu++17
find_package(Threads REQUIRED)

find_package(Boost 1.62.0 REQUIRED)
## Set our project name
project(mitama-dimensional)

include_directories(
PUBLIC ${Boost_INCLUDE_DIRS}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/tests
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/mitama-cpp-result/include
Expand All @@ -27,7 +28,6 @@ add_subdirectory(tests/basic-tests)
add_subdirectory(tests/delta-tests)
add_subdirectory(tests/derived-unit-tests)
add_subdirectory(tests/format-io-tests)
add_subdirectory(tests/literal-tests)
add_subdirectory(tests/math-tests)
add_subdirectory(tests/nonsi-unit-tests)
add_subdirectory(tests/refinement-tests)
add_subdirectory(tests/static-quantity-tests)
26 changes: 0 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Please refer to the [document](https://loligothick.github.io/mitama-dimensional/
- pre defined SI derived units
- **USER DEFINED DIMENSION**
- formatted output
- dimensional refinement

## Examples

Expand Down Expand Up @@ -99,31 +98,6 @@ int main() {
}
```

- [dimensional refinement](https://loligothick.github.io/mitama-dimensional/UserManual/dimensional-refinement/)

```cpp
#include <dimensional/quantity.hpp>
#include <dimensional/arithmetic.hpp>
#include <dimensional/systems/si/all.hpp>
#include <dimensional/systems/si/derived_units/area.hpp>
#include <dimensional/refinement.hpp>

int main() {
namespace si = mitama::systems::si;
using mitama::accepts_for, mitama::sym::L;

// width = 2 m
mitama::quantity_t<si::meter_t, int> width = 2;
// height = 3 mm
mitama::quantity_t<si::millimeter_t, int> height = 3;
// area = 6000 mm^2
mitama::quantity_t area = accepts_for<L<2>> |= width * height;
// ^~~~~~~~~~~~~~~~
// refine for L^2
}
```


- [user defined dimension example](https://loligothick.github.io/mitama-dimensional/UserManual/user-defined-dimension/)


Expand Down
2 changes: 1 addition & 1 deletion example/overview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <dimensional/systems/si/derived_units/area.hpp>
#include <dimensional/systems/si/derived_units/angle.hpp>
#include <dimensional/io.hpp>
#include <dimensional/refinement.hpp>

#include <dimensional/systems/si/prefix.hpp>
#include <dimensional/math/all.hpp>
#include <dimensional/systems/currency/jpy.hpp>
Expand Down
63 changes: 63 additions & 0 deletions include/dimensional/dimensional.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#ifndef MITAMA_DIMENSIONAL_HPP
#define MITAMA_DIMENSIONAL_HPP
#include <mitama/dimensional/fwd/dimensional_fwd.hpp>
#include <mitama/dimensional/fwd/system.hpp>
#include <mitama/dimensional/mitamagic/utility_ext.hpp>
#include <mitama/dimensional/mitamagic/type_traits_ext.hpp>
#include <mitama/dimensional/mitamagic/ratio_ext.hpp>
#include <mitama/dimensional/mitamagic/type_list.hpp>
#include <type_traits>

namespace mitama::mitamagic {
template <class T, class... Types>
inline constexpr std::size_t dimension_count_v =
(static_cast<std::size_t>(std::is_same_v<typename T::dimension_type,
typename Types::dimension_type>) +
... + std::size_t{}); // type count meta-function
} // namespace mitama::mitamagic

namespace mitama {

template < class >
struct si_base_units {};

template <int I, class Dim, class Exponent> struct dimension_tag {};

template <class... Units>
struct dimensional_t : private Units::tag... // for Dimensional tags
{
template < class T >
struct is_wildcard : std::is_same<T, system<>> {};
// sanity check for duplicate
static_assert(std::conjunction_v<std::bool_constant<
(mitamagic::dimension_count_v<Units, Units...> == 1)>...>,
"same dimension is not allowed");
// sanity check for system
static_assert(mitamagic::tlist_all_same_v<
mitamagic::tlist_remove_if_t<is_wildcard,
mitamagic::type_list<typename Units::system_type...>>>,
"different units within a dimension");
static constexpr std::size_t value = sizeof...(Units);
using system_type
= mitamagic::tlist_element_t<0,
std::conditional_t<
std::is_same_v<
mitamagic::type_list<>,
mitamagic::tlist_remove_if_t<is_wildcard,
mitamagic::type_list<typename Units::system_type...>
>
>,
mitamagic::type_list<system<>>,
mitamagic::tlist_remove_if_t<is_wildcard,
mitamagic::type_list<typename Units::system_type...>
>
>
>;
};

template <class... Units>
using make_dimensional_t = si_base_units<dimensional_t<Units...>>;


} // namespace mitama
#endif
Loading

0 comments on commit 05f6cf8

Please sign in to comment.