Skip to content

Commit

Permalink
Use fmt header only
Browse files Browse the repository at this point in the history
  • Loading branch information
fintarin committed Apr 28, 2024
1 parent 7d7f792 commit 8111cfb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ target_include_directories(

target_link_libraries(
${PROJECT_NAME}
PUBLIC fmt::fmt
PUBLIC fmt::fmt-header-only
cppcoro
MPFR
Boost::multiprecision
Expand Down
9 changes: 6 additions & 3 deletions src/fintamath/numbers/RealFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ namespace fintamath {

using namespace detail;

namespace {

constexpr std::string_view backendIsInfException = "Undefined backend inf";
constexpr std::string_view backendIsNegInfException = "Undefined backend -inf";
constexpr std::string_view backendIsNanException = "Undefined backend nan";

namespace {

bool isOverflow(const Real &rhs) {
static Cache<unsigned, Real::Backend> cache([](const unsigned precision) {
static const Real::Backend powBase = 10;
Expand Down Expand Up @@ -173,7 +173,9 @@ catch (const UndefinedException &exc) {
}

Real log(const Real &lhs, const Real &rhs) try {
return ln(rhs) / ln(lhs);
Real divLhs = ln(rhs);
Real divRhs = ln(lhs);
return divLhs / divRhs;
}
catch (const UndefinedException &exc) {
throw UndefinedException(fmt::format(
Expand Down Expand Up @@ -527,4 +529,5 @@ const Real &getPi() {

return cache[Real::getCalculationPrecision()];
}

}
4 changes: 2 additions & 2 deletions tests/src/numbers/RealFunctionsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,11 +579,11 @@ TEST(RealFunctionsTests, logTest) {
EXPECT_THAT(
[] { log(Real("0"), Real("-0")); },
testing::ThrowsMessage<UndefinedException>(
testing::StrEq("log(0.0, -0.0) is undefined (ln(0.0) is undefined (expected argument > 0))")));
testing::StrEq("log(0.0, -0.0) is undefined (ln(-0.0) is undefined (expected argument > 0))")));
EXPECT_THAT(
[] { log(Real("-0"), Real("0")); },
testing::ThrowsMessage<UndefinedException>(
testing::StrEq("log(-0.0, 0.0) is undefined (ln(-0.0) is undefined (expected argument > 0))")));
testing::StrEq("log(-0.0, 0.0) is undefined (ln(0.0) is undefined (expected argument > 0))")));
EXPECT_THAT(
[] { log(Real("-0"), Real("-0")); },
testing::ThrowsMessage<UndefinedException>(
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set(CMAKE_MODULE_PATH
PARENT_SCOPE)

add_subdirectory(fmt)
suppress_warnings(fmt)
suppress_warnings(fmt-header-only)

add_subdirectory(cppcoro)
suppress_warnings(cppcoro)
Expand Down

0 comments on commit 8111cfb

Please sign in to comment.