@@ -4,41 +4,41 @@ Date: Wed, 29 May 2024 16:29:55 -0700
44Subject: [PATCH 1/8] Use fmtlib
55
66---
7- include/.styleguide | 1 +
8- include/sleipnir/util/assert.hpp | 5 +++--
9- include/sleipnir/util/print.hpp | 31 ++++++++++++++++++-------------
10- src/.styleguide | 1 +
11- src/optimization/problem.cpp | 1 +
12- 5 files changed, 24 insertions(+), 15 deletions(-)
7+ include/sleipnir/optimization/problem.hpp | 1 +
8+ include/sleipnir/util/assert.hpp | 5 ++--
9+ include/sleipnir/util/print.hpp | 31 +++++++++++++----------
10+ 3 files changed, 22 insertions(+), 15 deletions(-)
1311
14- diff --git a/include/.styleguide b/include/.styleguide
15- index 1b6652d3d5886cf8c9eca0d855c21031775bad7c..4f4c76204071f90bf49eddb8c2aceb583b5e09ba 100644
16- --- a/include/.styleguide
17- +++ b/include/.styleguide
18- @@ -8,5 +8,6 @@ cppSrcFileInclude {
12+ diff --git a/include/sleipnir/optimization/problem.hpp b/include/sleipnir/optimization/problem.hpp
13+ index 3185466605b6604068e2807e461d07d8c856c505..95a33952a5a368c7c81491dbe849a8096357dc38 100644
14+ --- a/include/sleipnir/optimization/problem.hpp
15+ +++ b/include/sleipnir/optimization/problem.hpp
16+ @@ -15,6 +15,7 @@
1917
20- includeOtherLibs {
21- ^Eigen/
22- + ^fmt/
23- ^gch/
24- }
18+ #include <Eigen/Core>
19+ #include <Eigen/SparseCore>
20+ + #include <fmt/chrono.h>
21+ #include <gch/small_vector.hpp>
22+
23+ #include "sleipnir/autodiff/expression_type.hpp"
2524diff --git a/include/sleipnir/util/assert.hpp b/include/sleipnir/util/assert.hpp
26- index 75d8ffca32accbf66ffce30f073de1db2f42469b..53de01928b929793fa77885ec4a6d1a928bdc5a9 100644
25+ index 0846928c3da7a6047a3c271dd2d377a3b755eeab..5d432608def05b6dee6b7cbdb9a0b91a6ab5e1c2 100644
2726--- a/include/sleipnir/util/assert.hpp
2827+++ b/include/sleipnir/util/assert.hpp
29- @@ -3,9 +3,10 @@
30- #pragma once
28+ @@ -4,10 +4,11 @@
29+
30+ #ifdef SLEIPNIR_PYTHON
3131
32- #ifdef JORMUNGANDR
3332- #include <format>
3433 #include <source_location>
3534 #include <stdexcept>
36- +
35+
3736+ #include <fmt/format.h>
37+ +
3838 /**
3939 * Throw an exception in Python.
4040 */
41- @@ -13 ,7 +14 ,7 @@
41+ @@ -15 ,7 +16 ,7 @@
4242 do { \
4343 if (!(condition)) { \
4444 auto location = std::source_location::current(); \
@@ -48,7 +48,7 @@ index 75d8ffca32accbf66ffce30f073de1db2f42469b..53de01928b929793fa77885ec4a6d1a9
4848 location.line(), location.function_name(), #condition)); \
4949 } \
5050diff --git a/include/sleipnir/util/print.hpp b/include/sleipnir/util/print.hpp
51- index fe430352dabf4cd6a890dc8007237c7a261dfd4b..055d5c9fa246201f1d8ae7ddca00b1159aeb2a57 100644
51+ index 797df849f63d960cf10eaf847415595961868ab0..a89b7d4f9864965443405a8e79cddd8dbfc54ad3 100644
5252--- a/include/sleipnir/util/print.hpp
5353+++ b/include/sleipnir/util/print.hpp
5454@@ -4,10 +4,15 @@
@@ -76,8 +76,8 @@ index fe430352dabf4cd6a890dc8007237c7a261dfd4b..055d5c9fa246201f1d8ae7ddca00b115
7676+ * Wrapper around fmt::print() that squelches write failure exceptions.
7777 */
7878 template <typename... T>
79- - inline void print(std::format_string<T...> fmt, T&&... args) {
80- + inline void print(fmt::format_string<T...> fmt, T&&... args) {
79+ - void print(std::format_string<T...> fmt, T&&... args) {
80+ + void print(fmt::format_string<T...> fmt, T&&... args) {
8181 try {
8282- std::print(fmt, std::forward<T>(args)...);
8383+ fmt::print(fmt, std::forward<T>(args)...);
@@ -90,8 +90,8 @@ index fe430352dabf4cd6a890dc8007237c7a261dfd4b..055d5c9fa246201f1d8ae7ddca00b115
9090+ * Wrapper around fmt::print() that squelches write failure exceptions.
9191 */
9292 template <typename... T>
93- - inline void print(std::FILE* f, std::format_string<T...> fmt, T&&... args) {
94- + inline void print(std::FILE* f, fmt::format_string<T...> fmt, T&&... args) {
93+ - void print(std::FILE* f, std::format_string<T...> fmt, T&&... args) {
94+ + void print(std::FILE* f, fmt::format_string<T...> fmt, T&&... args) {
9595 try {
9696- std::print(f, fmt, std::forward<T>(args)...);
9797+ fmt::print(f, fmt, std::forward<T>(args)...);
@@ -104,8 +104,8 @@ index fe430352dabf4cd6a890dc8007237c7a261dfd4b..055d5c9fa246201f1d8ae7ddca00b115
104104+ * Wrapper around fmt::println() that squelches write failure exceptions.
105105 */
106106 template <typename... T>
107- - inline void println(std::format_string<T...> fmt, T&&... args) {
108- + inline void println(fmt::format_string<T...> fmt, T&&... args) {
107+ - void println(std::format_string<T...> fmt, T&&... args) {
108+ + void println(fmt::format_string<T...> fmt, T&&... args) {
109109 try {
110110- std::println(fmt, std::forward<T>(args)...);
111111+ fmt::println(fmt, std::forward<T>(args)...);
@@ -118,34 +118,11 @@ index fe430352dabf4cd6a890dc8007237c7a261dfd4b..055d5c9fa246201f1d8ae7ddca00b115
118118+ * Wrapper around fmt::println() that squelches write failure exceptions.
119119 */
120120 template <typename... T>
121- - inline void println(std::FILE* f, std::format_string<T...> fmt, T&&... args) {
122- + inline void println(std::FILE* f, fmt::format_string<T...> fmt, T&&... args) {
121+ - void println(std::FILE* f, std::format_string<T...> fmt, T&&... args) {
122+ + void println(std::FILE* f, fmt::format_string<T...> fmt, T&&... args) {
123123 try {
124124- std::println(f, fmt, std::forward<T>(args)...);
125125+ fmt::println(f, fmt, std::forward<T>(args)...);
126126 } catch (const std::system_error&) {
127127 }
128128 }
129- diff --git a/src/.styleguide b/src/.styleguide
130- index 1b6652d3d5886cf8c9eca0d855c21031775bad7c..4f4c76204071f90bf49eddb8c2aceb583b5e09ba 100644
131- --- a/src/.styleguide
132- +++ b/src/.styleguide
133- @@ -8,5 +8,6 @@ cppSrcFileInclude {
134-
135- includeOtherLibs {
136- ^Eigen/
137- + ^fmt/
138- ^gch/
139- }
140- diff --git a/src/optimization/problem.cpp b/src/optimization/problem.cpp
141- index c3331197e2365934273f57422b79fa18c2b78a5b..09828cdb6d7cddff692b9d17603dc0c11cd5a3ec 100644
142- --- a/src/optimization/problem.cpp
143- +++ b/src/optimization/problem.cpp
144- @@ -11,6 +11,7 @@
145-
146- #include <Eigen/Core>
147- #include <Eigen/SparseCore>
148- + #include <fmt/chrono.h>
149- #include <gch/small_vector.hpp>
150-
151- #include "optimization/bounds.hpp"
0 commit comments