-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from LoliGothick/develop
Major update
- Loading branch information
Showing
535 changed files
with
1,639 additions
and
4,488 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.