1 #ifndef CPPAD_CG_LANG_STREAM_STACK_INCLUDED 2 #define CPPAD_CG_LANG_STREAM_STACK_INCLUDED 37 _text(std::move(text)) {
44 const std::string& getText()
const {
61 std::forward_list<_private::LangStreamOperation<Base> > _cache;
62 typename std::forward_list<_private::LangStreamOperation<Base> >::iterator _it;
66 _it(_cache.before_begin()) {
69 inline bool empty()
const {
70 return _cache.empty();
75 _it = _cache.before_begin();
82 while (!_cache.empty() && _cache.begin()->getNode() ==
nullptr) {
83 _out << _cache.begin()->getText();
84 _cache.erase_after(_cache.before_begin());
86 _it = _cache.before_begin();
90 CPPAD_ASSERT_KNOWN(!_cache.empty(),
"Cannot extract an operation node from an empty list")
91 CPPAD_ASSERT_KNOWN(_cache.begin()->getNode() !=
nullptr,
"The first element in the list is not an OperationNode")
93 _cache.erase_after(_cache.before_begin());
94 _it = _cache.before_begin();
100 if (lss._it == lss._cache.before_begin()) {
103 lss._it = lss._cache.emplace_after(lss._it, std::move(text));
109 return (lss << std::to_string(i));
113 return (lss << std::to_string(i));
117 return (lss << std::to_string(i));
121 return (lss << std::to_string(i));
125 return (lss << std::to_string(i));
128 friend inline LangStreamStack<Base>& operator<<(LangStreamStack<Base>& lss,
long long unsigned int i) {
129 return (lss << std::to_string(i));
133 return (lss << std::string(1, text));
137 lss._it = lss._cache.emplace_after(lss._it, node);