Skip to content

Commit

Permalink
feat: add module mp_units
Browse files Browse the repository at this point in the history
  • Loading branch information
JohelEGP committed Aug 30, 2023
1 parent fa38e4f commit 3a3304b
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 5 deletions.
10 changes: 10 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ target_link_libraries(
add_library(mp-units::mp-units ALIAS mp-units)
install(TARGETS mp-units EXPORT mp-unitsTargets)

# C++ module
if(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API)
add_library(mp-units-module STATIC)
add_library(mp-units::module ALIAS mp-units-module)
target_sources(
mp-units-module PUBLIC FILE_SET CXX_MODULES BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES "mp-units.cpp"
)
target_link_libraries(mp-units-module PRIVATE mp-units::mp-units)
endif()

# local build
export(EXPORT mp-unitsTargets NAMESPACE mp-units::)
configure_file("mp-unitsConfig.cmake" "." COPYONLY)
Expand Down
2 changes: 1 addition & 1 deletion src/core-fmt/include/mp-units/bits/fmt_hacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ MP_UNITS_DIAGNOSTIC_POP

#else

#ifndef __cpp_lib_format
#if !defined(__cpp_lib_format) && !defined(__cpp_lib_format_ranges)
#error "std::formatting facility not supported"
#endif

Expand Down
58 changes: 58 additions & 0 deletions src/mp-units.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
module;

// core
#include <gsl/gsl-lite.hpp>
#include <array>
#include <compare>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <initializer_list>
#include <iterator>
#include <limits>
#include <numbers>
#include <numeric>
#include <optional>
#include <ranges>
#include <string>
#include <string_view>
#include <tuple>
#include <type_traits>
#include <utility>

// core-io
#include <sstream>

// core-fmt
#include <format>

// utility
#include <chrono>
#include <cmath>
#include <random>

export module mp_units;

export
{
// core
#include <mp-units/core.h>

// core-io
#include <mp-units/ostream.h>

// core-fmt
#include <mp-units/format.h>

// systems
#include <mp-units/systems/angular/angular.h>
#include <mp-units/systems/iec80000/iec80000.h>
#include <mp-units/systems/isq/isq.h>
#include <mp-units/systems/si/si.h>

// utility
#include <mp-units/chrono.h>
#include <mp-units/math.h>
#include <mp-units/random.h>
}
8 changes: 4 additions & 4 deletions src/utility/include/mp-units/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace mp_units {

namespace detail {
template<Quantity Q, typename InputIt>
static std::vector<typename Q::rep> i_qty_to_rep(InputIt first, InputIt last)
std::vector<typename Q::rep> i_qty_to_rep(InputIt first, InputIt last)
{
std::vector<typename Q::rep> intervals_rep;
intervals_rep.reserve(static_cast<size_t>(std::distance(first, last)));
Expand All @@ -41,7 +41,7 @@ static std::vector<typename Q::rep> i_qty_to_rep(InputIt first, InputIt last)
}

template<Quantity Q>
static std::vector<typename Q::rep> bl_qty_to_rep(std::initializer_list<Q>& bl)
std::vector<typename Q::rep> bl_qty_to_rep(std::initializer_list<Q>& bl)
{
std::vector<typename Q::rep> bl_rep;
bl_rep.reserve(bl.size());
Expand All @@ -52,7 +52,7 @@ static std::vector<typename Q::rep> bl_qty_to_rep(std::initializer_list<Q>& bl)
}

template<Quantity Q, typename UnaryOperation>
inline static std::vector<typename Q::rep> fw_bl_pwc(std::initializer_list<Q>& bl, UnaryOperation fw)
std::vector<typename Q::rep> fw_bl_pwc(std::initializer_list<Q>& bl, UnaryOperation fw)
{
using rep = MP_UNITS_TYPENAME Q::rep;
std::vector<rep> w_bl;
Expand All @@ -70,7 +70,7 @@ inline static std::vector<typename Q::rep> fw_bl_pwc(std::initializer_list<Q>& b
}

template<Quantity Q, typename UnaryOperation>
static std::vector<typename Q::rep> fw_bl_pwl(std::initializer_list<Q>& bl, UnaryOperation fw)
std::vector<typename Q::rep> fw_bl_pwl(std::initializer_list<Q>& bl, UnaryOperation fw)
{
std::vector<typename Q::rep> weights;
weights.reserve(bl.size());
Expand Down

0 comments on commit 3a3304b

Please sign in to comment.