<div dir="ltr"><div dir="ltr">On Tue, Jun 25, 2019 at 3:23 PM denisgolovan <<a href="mailto:denisgolovan@yandex.ru">denisgolovan@yandex.ru</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
e.g. what about returning dynamic arrays? Like:<br>
<br>
type TIntArray = array of Integer;<br>
function ArrInit(): TIntArray;<br>
begin<br>
  SetLength(Result, 1);<br>
  Result[0]:=1;<br>
end;<br></blockquote><div><br></div><div>Stuff like that is pretty much impossible, because you can't dynamically allocate memory at compile time.</div><div><br></div><div><a href="https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(j:1,lang:c%2B%2B,source:'%23include+%3Ciostream%3E%0A%23include+%3Cmemory%3E%0A%23include+%3Cvector%3E%0A%23include+%3Cstring%3E%0A%0Ausing+std::cout%3B%0Ausing+std::unique_ptr%3B%0Ausing+std::make_unique%3B%0Ausing+std::vector%3B%0Ausing+std::string%3B%0A%0Atemplate+%3Ctypename+T%3E+using+TVecPtr+%3D+vector%3CT%3E%3B%0A%0Atemplate+%3Ctypename+T%3E+using+TDynArray+%3D+unique_ptr%3CTVecPtr%3CT%3E%3E%3B%0A%0Atemplate+%3Ctypename+T,+typename...+Values%3E%0Aconstexpr+TDynArray%3CT%3E+DynArray(Values...+vals)+%7B%0A++return+make_unique%3CTVecPtr%3CT%3E%3E(vector%3CT%3E%7Bvals...%7D)%3B%0A%7D%0A%0Aint+main()+%7B%0A++const+auto+Strings+%3D+DynArray%3Cstring%3E(%0A++++%22Pascal!'s%22,%0A++++%22real%22,%0A++++%22dynamic%22,%0A++++%22arrays%22,%0A++++%22are%22,%0A++++%22much%22,%0A++++%22nicer!!%22%0A++)%3B%0A++for+(auto+S+:+*Strings)+%7B%0A++++cout+%3C%3C+S+%3C%3C+%22%5Cn%22%3B%0A++%7D%0A%7D'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:50.745098039215684,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:clang_trunk,filters:(b:'0',binary:'1',commentOnly:'0',demangle:'0',directives:'0',execute:'0',intel:'0',libraryCode:'1',trim:'1'),lang:c%2B%2B,libs:!(),options:'-O3',source:1),l:'5',n:'0',o:'x86-64+clang+(trunk)+(Editor+%231,+Compiler+%231)+C%2B%2B',t:'0')),k:49.254901960784316,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4">See here</a> for a C++ example. Note how the function being marked constexpr doesn't actually do anything special in that particular case, and if you try to initialize the array with "constexpr auto" instead of "const auto", the whole program just won't compile.</div></div></div>