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 #include <gtsam/dllexport.h>
8 
9 namespace gtsam {
16 struct GTSAM_EXPORT RedirectCout {
18  RedirectCout() : ssBuffer_(), coutBuffer_(std::cout.rdbuf(ssBuffer_.rdbuf())) {}
19 
21  std::string str() const;
22 
24  ~RedirectCout();
25 
26 private:
27  std::stringstream ssBuffer_;
28  std::streambuf* coutBuffer_;
29 };
30 
31 }
32 
33 namespace gtsam {
34 // Adapted from https://stackoverflow.com/a/32223343/9151520
35 // An adaptation of boost::mp11::index_sequence
36 template <size_t... Ints>
39  using value_type = size_t;
40  static constexpr std::size_t size() noexcept { return sizeof...(Ints); }
41 };
42 namespace detail {
43 template <class Sequence1, class Sequence2>
45 
46 template <size_t... I1, size_t... I2>
48  : index_sequence<I1..., (sizeof...(I1) + I2)...> {};
49 } // namespace detail
50 template <size_t N>
51 struct make_index_sequence : detail::_merge_and_renumber<typename make_index_sequence<N / 2>::type,
52  typename make_index_sequence<N - N / 2>::type> {};
53 template <>
55 template <>
57 template <class... T>
59 } // namespace gtsam
gtsam::RedirectCout
Definition: base/utilities.h:16
detail
Definition: testSerializationNonlinear.cpp:70
gtsam::RedirectCout::coutBuffer_
std::streambuf * coutBuffer_
Definition: base/utilities.h:28
gtsam::index_sequence< I1...,(sizeof...(I1)+I2)... >::value_type
size_t value_type
Definition: base/utilities.h:39
gtsam::RedirectCout::ssBuffer_
std::stringstream ssBuffer_
Definition: base/utilities.h:27
gtsam::RedirectCout::RedirectCout
RedirectCout()
constructor – redirect stdout buffer to a stringstream buffer
Definition: base/utilities.h:18
gtsam::detail::_merge_and_renumber
Definition: base/utilities.h:44
gtsam::make_index_sequence
Definition: base/utilities.h:51
Eigen::Triplet
A small structure to hold a non zero as a triplet (i,j,value).
Definition: SparseUtil.h:162
size_t
std::size_t size_t
Definition: wrap/pybind11/include/pybind11/detail/common.h:490
gtsam::index_sequence
Definition: base/utilities.h:37
gtsam
traits
Definition: SFMdata.h:40
gtsam::index_sequence::size
static constexpr std::size_t size() noexcept
Definition: base/utilities.h:40
std
Definition: BFloat16.h:88
gtsam.examples.ShonanAveragingCLI.str
str
Definition: ShonanAveragingCLI.py:115


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:09:40