File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -284,6 +284,19 @@ struct DebugFormatArgumentAdaptor<std::string_view>
284284 }
285285};
286286
287+ /* *
288+ * String view specialisation, use the C string handler.
289+ */
290+ template <>
291+ struct DebugFormatArgumentAdaptor <std::string>
292+ {
293+ __always_inline static DebugFormatArgument construct (std::string &value)
294+ {
295+ return DebugFormatArgumentAdaptor<const char *>::construct (
296+ value.c_str ());
297+ }
298+ };
299+
287300/* *
288301 * Enum specialisation, prints the enum as a string and then the numeric value.
289302 *
Original file line number Diff line number Diff line change 44#include " tests.hh"
55#include < compartment.h>
66#include < simulator.h>
7+ #include < string>
78
89using namespace CHERI ;
10+ using namespace std ::string_literals;
911
1012namespace
1113{
@@ -104,10 +106,10 @@ void __cheri_compartment("test_runner") run_tests()
104106 0x123456789012345ULL );
105107 const char *testString = " Hello, world! with some trailing characters" ;
106108 // Make sure that we don't print the trailing characters
107- debug_log (" Trying to print string: {} " , std::string_view{testString, 13 });
108- std::string hi = " Hello world " ;
109- debug_log ( " Trying to print std::string: {} " , hi. c_str ()) ;
110-
109+ debug_log (" Trying to print std::string_view: {} " ,
110+ std::string_view{testString, 13 }) ;
111+ const std::string S = " I am a walrus " s ;
112+ debug_log ( " Trying to print std::string: {} " , S);
111113 run_timed (" All tests" , []() {
112114 run_timed (" Debug helpers (C++)" , test_debug_cxx);
113115 run_timed (" Debug helpers (C)" , test_debug_c);
You can’t perform that action at this time.
0 commit comments