base/utilities.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <iostream>
5 #include <sstream>
6 
7 namespace gtsam {
14 struct RedirectCout {
16  RedirectCout() : ssBuffer_(), coutBuffer_(std::cout.rdbuf(ssBuffer_.rdbuf())) {}
17 
19  std::string str() const;
20 
22  ~RedirectCout();
23 
24 private:
25  std::stringstream ssBuffer_;
26  std::streambuf* coutBuffer_;
27 };
28 
29 }
30 
31 namespace gtsam {
32 // Adapted from https://stackoverflow.com/a/32223343/9151520
33 // An adaptation of boost::mp11::index_sequence
34 template <size_t... Ints>
37  using value_type = size_t;
38  static constexpr std::size_t size() noexcept { return sizeof...(Ints); }
39 };
40 namespace detail {
41 template <class Sequence1, class Sequence2>
43 
44 template <size_t... I1, size_t... I2>
46  : index_sequence<I1..., (sizeof...(I1) + I2)...> {};
47 } // namespace detail
48 template <size_t N>
49 struct make_index_sequence : detail::_merge_and_renumber<typename make_index_sequence<N / 2>::type,
50  typename make_index_sequence<N - N / 2>::type> {};
51 template <>
53 template <>
55 template <class... T>
57 } // namespace gtsam
Definition: BFloat16.h:88
std::string str() const
return the string
Definition: utilities.cpp:5
static constexpr std::size_t size() noexcept
traits
Definition: chartTesting.h:28
~RedirectCout()
destructor – redirect stdout buffer to its original buffer
Definition: utilities.cpp:9
std::streambuf * coutBuffer_
std::stringstream ssBuffer_
RedirectCout()
constructor – redirect stdout buffer to a stringstream buffer


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:40:43