Request Short Link
C++ 98
C++ 11
C++ 14
C++ 17
C++ 20
C++ 23
C++ 2c
for-loops as while-loops
array subscription
Show all implicit casts
Show all template parameters of a CallExpr
Use libc++
Transform std::initializer_list
Show noexcept internals
Show padding information
Show coroutine transformation
Show C++ to C transformation
Show object lifetime
Default
15
18
20
22
26
More
GitHub
Patreon
Issues
About
Policies
Examples
C++ Insights @ YouTube
Settings
Version
None
×
Made by
Andreas Fertig
Powered by
Flask
and
CodeMirror
Source:
#include <array> template<typename Inner> struct Wrap { Wrap(Inner const& inner) : m_inner(inner) {} Inner m_inner; }; template<typename It, typename Transformer> class transform_iterator : Wrap<Transformer> { It m_it; public: transform_iterator(It const& it, Transformer const& transformer) : m_it(it), Wrap<Transformer>(transformer) {} //Other members omitted for simplicity Wrap<Transformer> get_base() const { return *this; } }; void test() { std::array<int, 2> a = { 99, 42 }; auto orig=begin(a); auto transformed=transform_iterator(orig, [](int v) { return v + 1; }); static_assert( sizeof(orig)==8 && sizeof(transformed)==16 && sizeof(transformed.get_base())==1, "Failure!"); }
Insight:
Console: