Skip to content

Commit

Permalink
Fix compilation errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
pleroy committed May 5, 2024
1 parent 75d5b36 commit a04b101
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 32 deletions.
1 change: 1 addition & 0 deletions boost_multiprecision.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(SolutionDir)..\Boost\multiprecision\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>BOOST_MP_STANDALONE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup />
Expand Down
5 changes: 0 additions & 5 deletions functions/functions.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
<ProjectGuid>{7cca653c-2e8f-4ffd-9e9f-bee590f3efab}</ProjectGuid>
<RootNamespace>functions</RootNamespace>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>BOOST_MP_STANDALONE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="accurate_table_generator.hpp" />
<ClInclude Include="accurate_table_generator_body.hpp" />
Expand Down
2 changes: 1 addition & 1 deletion numerics/polynomial_in_monomial_basis_body.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "absl/strings/str_cat.h"
#include "absl/strings/str_join.h"
#include "base/not_constructible.hpp"
#include "boost/multiprecision/fwd.hpp"
#include "boost/multiprecision/number.hpp"
#include "geometry/cartesian_product.hpp"
#include "geometry/serialization.hpp"
#include "numerics/combinatorics.hpp"
Expand Down
46 changes: 24 additions & 22 deletions quantities/concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ using namespace base::_traits;
using namespace quantities::_quantities;

// TODO(egg): additive_group should subsume affine, but we use it there.
// We use |convertible_to| here because we want this concept to work with
// Boost multiprecision types which heavily use implicit conversions.
template<typename G>
concept additive_group = requires(G x, G y, int n) {
G{};
Expand All @@ -34,10 +36,10 @@ concept additive_group = requires(G x, G y, int n) {
template<typename A>
concept affine = requires(A x, A y) {
{ x - y } -> additive_group;
{ y + (x - y) } -> std::convertible_to<A>;
{ y += (x - y) } -> std::convertible_to<A&>;
{ y - (x - y) } -> std::convertible_to<A>;
{ y -= (x - y) } -> std::convertible_to<A&>;
{ y + (x - y) } -> std::same_as<A>;
{ y += (x - y) } -> std::same_as<A&>;
{ y - (x - y) } -> std::same_as<A>;
{ y -= (x - y) } -> std::same_as<A&>;
};

// A graded ring restricted to its homogeneous elements; multiplication can
Expand All @@ -48,13 +50,13 @@ concept homogeneous_ring =
// Really, multiplication should return a homogeneous_ring.
{ x * y } -> additive_group;
{ (x * y) * z } -> additive_group;
{ (x * y) * z } -> std::convertible_to<decltype(x * (y * z))>;
{ (x * y) * z } -> std::same_as<decltype(x * (y * z))>;
};

template<typename A>
concept ring = homogeneous_ring<A> && requires(A x, A y) {
{ x * y } -> std::convertible_to<A>;
{ x *= y } -> std::convertible_to<A&>;
{ x * y } -> std::same_as<A>;
{ x *= y } -> std::same_as<A&>;
};

// TODO(egg): field should subsume homogeneous_field, but we use it in
Expand All @@ -63,21 +65,21 @@ concept ring = homogeneous_ring<A> && requires(A x, A y) {
template<typename K>
concept field = ring<K> && !std::integral<K> && requires(K x, K y, K z) {
{ 1 } -> std::convertible_to<K>;
{ 1 / y } -> std::convertible_to<K>;
{ x / y } -> std::convertible_to<K>;
{ x /= y } -> std::convertible_to<K&>;
{ 1 / y } -> std::same_as<K>;
{ x / y } -> std::same_as<K>;
{ x /= y } -> std::same_as<K&>;
};

// TODO(egg): vector_space should subsume homogeneous_vector_space, but we use
// it in homogeneous_vector_space.

template<typename V, typename K>
concept vector_space = field<K> && requires(K λ, V v) {
{ λ * v } -> std::convertible_to<V>;
{ v * λ } -> std::convertible_to<V>;
{ v / λ } -> std::convertible_to<V>;
{ v *= λ } -> std::convertible_to<V&>;
{ v /= λ } -> std::convertible_to<V&>;
{ λ * v } -> std::same_as<V>;
{ v * λ } -> std::same_as<V>;
{ v / λ } -> std::same_as<V>;
{ v *= λ } -> std::same_as<V&>;
{ v /= λ } -> std::same_as<V&>;
};

// A graded field restricted to its homogeneous elements; multiplication and
Expand All @@ -88,9 +90,9 @@ concept homogeneous_field = homogeneous_ring<K> && requires(K x, K y, K z) {
{ x / y } -> field;
requires vector_space<K, decltype(x / y)>;
{ (1 / x) } -> homogeneous_ring;
{ 1 / (x * y) } -> std::convertible_to<decltype((1 / x) * (1 / y))>;
{ (x * y) / z } -> std::convertible_to<K>;
{ (x / y) * z } -> std::convertible_to<K>;
{ 1 / (x * y) } -> std::same_as<decltype((1 / x) * (1 / y))>;
{ (x * y) / z } -> std::same_as<K>;
{ (x / y) * z } -> std::same_as<K>;
};

template<typename V, typename K>
Expand All @@ -99,11 +101,11 @@ concept homogeneous_vector_space =
// Really, these operations should return a homogeneous_vector_space.
requires vector_space<V, decltype(λ / μ)>;
{ λ * v } -> additive_group;
{ v * λ } -> std::convertible_to<decltype(λ * v)>;
{ v * λ } -> std::same_as<decltype(λ * v)>;
{ v / λ } -> additive_group;
{ λ * v / λ } -> std::convertible_to<V>;
{ λ * v / λ } -> std::same_as<V>;
{ (λ * μ) * v } -> additive_group;
{ λ * (μ * v) } -> std::convertible_to<decltype((λ * μ) * v)>;
{ λ * (μ * v) } -> std::same_as<decltype((λ * μ) * v)>;
};

template<typename V>
Expand All @@ -118,7 +120,7 @@ template<typename V>
concept real_affine_space = affine_space<V, double>;

template<typename T>
concept quantity = instance<T, Quantity> || std::convertible_to<T, double>;
concept quantity = instance<T, Quantity> || std::same_as<T, double>;

// std::integral || std::floating_point rather than
// std::convertible_to<double, T> because
Expand Down
2 changes: 1 addition & 1 deletion quantities/elementary_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <concepts>

#include "boost/multiprecision/fwd.hpp"
#include "boost/multiprecision/number.hpp"
#include "quantities/named_quantities.hpp"
#include "quantities/quantities.hpp"

Expand Down
1 change: 0 additions & 1 deletion quantities/elementary_functions_body.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <cmath>

#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/fwd.hpp"
#include "numerics/cbrt.hpp"
#include "numerics/fma.hpp"
#include "numerics/next.hpp"
Expand Down
2 changes: 1 addition & 1 deletion quantities/generators_body.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <tuple>

#include "base/not_constructible.hpp"
#include "boost/multiprecision/fwd.hpp"
#include "boost/multiprecision/number.hpp"
#include "quantities/dimensions.hpp"

namespace principia {
Expand Down
2 changes: 1 addition & 1 deletion quantities/quantities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "base/not_constructible.hpp"
#include "base/not_null.hpp"
#include "base/tags.hpp"
#include "boost/multiprecision/fwd.hpp"
#include "boost/multiprecision/number.hpp"
#include "quantities/dimensions.hpp"
#include "quantities/generators.hpp"
#include "serialization/quantities.pb.h"
Expand Down

0 comments on commit a04b101

Please sign in to comment.