THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2483 lines
121KB

  1. /* My tiny gzip decompressor without using zlib. - Joel Yliluoma
  2. * http://iki.fi/bisqwit/ , http://youtube.com/user/Bisqwit
  3. * Inspired and influenced by a 13th IOCCC winner program by Ron McFarland */
  4. /* Further optimized based on ideas from tinf library by Joergen Ibsen */
  5. /* Fun fact: Contains zero new/delete, and no STL data structures */
  6. /* Distributed under the terms of the Zlib license:
  7. Copyright (C) 2017 Joel Yliluoma
  8. This software is provided 'as-is', without any express or implied
  9. warranty. In no event will the authors be held liable for any damages
  10. arising from the use of this software.
  11. Permission is granted to anyone to use this software for any purpose,
  12. including commercial applications, and to alter it and redistribute it
  13. freely, subject to the following restrictions:
  14. 1. The origin of this software must not be misrepresented; you must not
  15. claim that you wrote the original software. If you use this software
  16. in a product, an acknowledgment in the product documentation would be
  17. appreciated but is not required.
  18. 2. Altered source versions must be plainly marked as such, and must not be
  19. misrepresented as being the original software.
  20. 3. This notice may not be removed or altered from any source distribution.
  21. */
  22. #include <assert.h>
  23. #include <utility> // std::forward
  24. #include <cstdint> // integer sizes
  25. #include <type_traits>
  26. #include <iterator>
  27. #if !1 //Documentation purposes only; the actual prototypes are littered with std::enable_ifs.
  28. // Deflate(): This is the public method declared (later) in this file.
  29. // Decompresses (inflates) deflate-compressed data, with a gzip or deflate header.
  30. // User-supplied functors:
  31. // input() returns the next byte from the (compressed) input.
  32. // output(byte) outputs one uncompressed byte.
  33. // outputcopy(length, offset) copies length uncompressed bytes from offset,
  34. // Offset is always >= 1.
  35. // offset 1 means previous byte,
  36. // offset 2 means previous before that and so on.
  37. // Note that (offset < length) is not an error and in fact happens frequently.
  38. // If length=0, offset indicates the largest look-behind window length that
  39. // you need to be prepared for. The length is a power-of-two in range 256..32768.
  40. //
  41. // If you want to implement range checking in input, return a negative value
  42. // from input() when there is no more input.
  43. //
  44. // If you want to implement range checking in output, add a return value
  45. // in output(): false=ok, true=abort; and a return value in outputcopy():
  46. // 0=ok, nonzero=one or more bytes were not writable.
  47. //
  48. // Results:
  49. // 0 = decompression complete
  50. // -1 = data error
  51. // -2 = input functor returned a value outside 0x00..0xFF range
  52. // -3 = output functor returned nonzero / bool true value
  53. // -4 = outputcopy functor returned nonzero remaining length value
  54. //
  55. template<typename InputFunctor, typename OutputFunctor, typename WindowFunctor>
  56. int Deflate(InputFunctor&& input, OutputFunctor&& output, WindowFunctor&& outputcopy);
  57. // Check README.md for the full list of versions of Deflate() available.
  58. #endif
  59. struct DeflateTrackTagBase{};
  60. struct DeflateTrackNoSize: public DeflateTrackTagBase{};
  61. struct DeflateTrackInSize: public DeflateTrackTagBase{};
  62. struct DeflateTrackOutSize: public DeflateTrackTagBase{};
  63. struct DeflateTrackBothSize: public DeflateTrackTagBase{};
  64. // The rest of the file is just for the curious about implementation.
  65. namespace gunzip_ns
  66. {
  67. // If you want more performance at the expense of RAM use,
  68. // Turn one or more of these settings to false:
  69. static constexpr bool USE_BITARRAY_TEMPORARY_IN_HUFFMAN_CREATION = false; /* 8 bytes save */
  70. static constexpr bool USE_BITARRAY_FOR_LENGTHS = false; /* 160 bytes save */
  71. static constexpr bool USE_BITARRAY_FOR_HUFFNODES = false; /* 392 bytes save */
  72. static constexpr unsigned MAX_WINDOW_SIZE = 32768u;
  73. static_assert(MAX_WINDOW_SIZE >= 1, "Max window size should be >= 1");
  74. static_assert(MAX_WINDOW_SIZE <= 32768u, "Window sizes larger than 32768 are not supported by deflate standard. Edit the source code to remove this assert if you need it.");
  75. //
  76. #define DEFLATE_USE_DATA_TABLES
  77. #if !defined(DEFLATE_ALLOCATION_AUTOMATIC) && !defined(DEFLATE_ALLOCATION_STATIC) && !defined(DEFLATE_ALLOCATION_DYNAMIC)
  78. // Choose one:
  79. #define DEFLATE_ALLOCATION_AUTOMATIC
  80. //#define DEFLATE_ALLOCATION_STATIC
  81. //#define DEFLATE_ALLOCATION_DYNAMIC
  82. #endif
  83. }
  84. /* A big list of conditions used in std::enable_if conditions. */
  85. #define DeflIsInputFunctor \
  86. (std::is_convertible<std::result_of_t<std::decay_t<InputFunctor>()>,int>::value /*\
  87. && !std::is_pointer<std::decay_t<InputFunctor>>::value*/)
  88. #define DeflIsOutputFunctor \
  89. (std::is_same<std::result_of_t<std::decay_t<OutputFunctor>(int)>,void>::value \
  90. || std::is_convertible<std::result_of_t<std::decay_t<OutputFunctor>(int)>,bool>::value)
  91. #define DeflIsWindowFunctor \
  92. (std::is_convertible<std::result_of_t<std::decay_t<WindowFunctor>(int,int)>,int>::value \
  93. || std::is_same<std::result_of_t<std::decay_t<WindowFunctor>(int,int)>,void>::value)
  94. #define DeflIsBacktrackFunctor \
  95. (std::is_same<std::result_of_t<std::decay_t<BacktrackFunctor>(bool)>,void>::value)
  96. #define DeflIsForwardIterator \
  97. (std::is_convertible<typename std::iterator_traits<std::decay_t<ForwardIterator>>::value_type, unsigned char>::value \
  98. && (std::is_same<typename std::iterator_traits<std::decay_t<ForwardIterator>>::iterator_category, std::forward_iterator_tag>::value \
  99. || std::is_same<typename std::iterator_traits<std::decay_t<ForwardIterator>>::iterator_category, std::bidirectional_iterator_tag>::value \
  100. || std::is_same<typename std::iterator_traits<std::decay_t<ForwardIterator>>::iterator_category, std::random_access_iterator_tag>::value))
  101. #define DeflIsBidirIterator \
  102. (std::is_convertible<typename std::iterator_traits<std::decay_t<BidirIterator>>::value_type, unsigned char>::value \
  103. && (std::is_same<typename std::iterator_traits<std::decay_t<BidirIterator>>::iterator_category, std::bidirectional_iterator_tag>::value \
  104. || std::is_same<typename std::iterator_traits<std::decay_t<BidirIterator>>::iterator_category, std::random_access_iterator_tag>::value))
  105. #define DeflIsInputIterator \
  106. (std::is_convertible<typename std::iterator_traits<std::decay_t<InputIterator>>::value_type, unsigned char>::value \
  107. && (std::is_same<typename std::iterator_traits<std::decay_t<InputIterator>>::iterator_category, std::input_iterator_tag>::value))
  108. #define DeflIsRandomAccessIterator \
  109. (std::is_convertible<typename std::iterator_traits<std::decay_t<RandomAccessIterator>>::value_type, unsigned char>::value \
  110. && !std::is_const<typename std::iterator_traits<std::decay_t<RandomAccessIterator>>::reference>::value \
  111. && std::is_same<typename std::iterator_traits<std::decay_t<RandomAccessIterator>>::iterator_category, std::random_access_iterator_tag>::value)
  112. #define DeflIsOutputIterator \
  113. (std::is_convertible<typename std::iterator_traits<std::decay_t<OutputIterator>>::value_type, unsigned char>::value \
  114. && !std::is_const<typename std::iterator_traits<std::decay_t<OutputIterator>>::reference>::value \
  115. && !std::is_pointer<std::decay_t<OutputIterator>>::value \
  116. && (std::is_same<typename std::iterator_traits<std::decay_t<OutputIterator>>::iterator_category, std::output_iterator_tag>::value \
  117. || std::is_same<typename std::iterator_traits<std::decay_t<OutputIterator>>::iterator_category, std::forward_iterator_tag>::value \
  118. || std::is_same<typename std::iterator_traits<std::decay_t<OutputIterator>>::iterator_category, std::bidirectional_iterator_tag>::value))
  119. #define DeflIsSizeType \
  120. (std::is_convertible<std::decay_t<SizeType>, std::size_t>::value \
  121. && !std::is_pointer<std::decay_t<SizeType>>::value)
  122. #define DeflIsSizeType2 \
  123. (std::is_convertible<std::decay_t<SizeType2>, std::size_t>::value \
  124. && !std::is_pointer<std::decay_t<SizeType2>>::value)
  125. #define DeflIsTrackTag \
  126. (std::is_base_of<DeflateTrackTagBase, std::decay_t<SizeTrackTag>>::value)
  127. #define DeflInputAbortable_Type(x) \
  128. (1* !(std::is_same<x, unsigned char>::value \
  129. || std::is_same<x, signed char>::value \
  130. || std::is_same<x, char>::value))
  131. #define DeflInputAbortable_InputFunctor \
  132. DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>)
  133. #define DeflOutputAbortable_OutputFunctor \
  134. (2* std::is_same<std::result_of_t<OutputFunctor(int)>, bool>::value)
  135. #define DeflOutputAbortable_WindowFunctor \
  136. (2* std::is_convertible<std::decay_t<std::result_of_t<WindowFunctor(int,int)>>, int>::value)
  137. #ifdef DEFLATE_ALLOCATION_DYNAMIC
  138. # include <memory>
  139. #endif
  140. // RandomAccessBitArray: An engine for arrays of data items that are not byte-aligned
  141. template<typename U = std::uint_least64_t>
  142. struct RandomAccessBitArrayBase
  143. {
  144. private:
  145. static constexpr unsigned Ubytes = sizeof(U), Ubits = Ubytes*8;
  146. static std::uint_fast64_t Get_Unclean(unsigned Size, const U* data, unsigned index) throw()
  147. {
  148. unsigned bitpos = index*Size, unitpos = bitpos / Ubits, shift = bitpos % Ubits;
  149. std::uint_fast64_t result = data[unitpos] >> shift;
  150. //assert(Size <= sizeof(result)*8);
  151. unsigned acquired = Ubits - shift;
  152. for(; acquired < Size; acquired += Ubits)
  153. {
  154. result += (std::uint_fast64_t)data[++unitpos] << acquired;
  155. }
  156. return result;
  157. }
  158. public:
  159. template<unsigned Size>
  160. static std::uint_fast64_t Get(const U* data, unsigned index) throw()
  161. {
  162. std::uint_fast64_t result = Get_Unclean(Size,data,index);
  163. return (Size >= sizeof(result)*8) ? result : (result & ((std::uint64_t(1) << Size)-1));
  164. }
  165. template<unsigned Size, bool update = false>
  166. static void Set(U* data, unsigned index, std::uint_fast64_t value) throw()
  167. {
  168. unsigned bitpos = index*Size, unitpos = bitpos / Ubits, eat = 0;
  169. // Make sure our storage unit is at least as bit as value
  170. //assert(Ubits >= sizeof(value)*8);
  171. //assert(Size >= sizeof(value)*8 || value < (std::uint64_t(1) << Size));
  172. if(Size % Ubits != 0)
  173. {
  174. unsigned shift = bitpos % Ubits;
  175. eat = Ubits - shift; if(eat > Size) eat = Size;
  176. //assert(eat < sizeof(std::uint_fast64_t)*8);
  177. //assert(shift + eat <= Ubits);
  178. std::uint_fast64_t vmask = (std::uint64_t(1) << eat)-1;
  179. if(update)
  180. data[unitpos] = (data[unitpos] & ~(vmask << shift)) | (value << shift);
  181. else
  182. data[unitpos] |= value << shift;
  183. //assert(eat < sizeof(value)*8);
  184. value >>= eat;
  185. ++unitpos;
  186. }
  187. if(eat < Size)
  188. for(unsigned remain = Size-eat; ; ++unitpos)
  189. {
  190. eat = Ubits;
  191. if(eat > remain)
  192. {
  193. eat = remain;
  194. if(update)
  195. {
  196. std::uint_fast64_t vmask = ((std::uint64_t(1) << eat)-1);
  197. data[unitpos] = (data[unitpos] & ~vmask) | value;
  198. }
  199. else
  200. {
  201. data[unitpos] |= value;
  202. }
  203. break;
  204. }
  205. else
  206. {
  207. data[unitpos] = value;
  208. value >>= Ubits/2; value >>= Ubits/2;
  209. remain -= Ubits;
  210. if(!remain) break;
  211. }
  212. }
  213. }
  214. };
  215. template<unsigned Nbits, typename U = std::uint_least64_t>
  216. struct RandomAccessBitArray
  217. {
  218. static constexpr unsigned Ubytes = sizeof(U), Ubits = Ubytes*8, Nunits = (Nbits+Ubits-1)/Ubits;
  219. U data[Nunits];
  220. template<unsigned Size>
  221. inline std::uint_fast64_t Get(unsigned index) const throw()
  222. {
  223. return RandomAccessBitArrayBase<U>::template Get<Size>(data, index);
  224. }
  225. template<unsigned Size, bool update = false>
  226. inline void Set(unsigned index, std::uint_fast64_t value) throw()
  227. {
  228. RandomAccessBitArrayBase<U>::template Set<Size,update>(data, index, value);
  229. }
  230. };
  231. namespace gunzip_ns
  232. {
  233. struct dummy{};
  234. // Utility: ceil(log2(n))
  235. template<unsigned long N> struct CeilLog2_s{ static constexpr unsigned result = 1+CeilLog2_s<(N+1)/2>::result; };
  236. template<> struct CeilLog2_s<0> { static constexpr unsigned result = 0; };
  237. template<> struct CeilLog2_s<1> { static constexpr unsigned result = 0; };
  238. template<unsigned long N> static constexpr unsigned CeilLog2 = CeilLog2_s<N>::result;
  239. // Utility: floor(log2(n))
  240. template<unsigned long N> struct FloorLog2_s{ static constexpr unsigned result = 1+FloorLog2_s<N/2>::result; };
  241. template<> struct FloorLog2_s<0> { static constexpr unsigned result = 0; };
  242. template<> struct FloorLog2_s<1> { static constexpr unsigned result = 0; };
  243. template<unsigned long N> static constexpr unsigned FloorLog2 = FloorLog2_s<N>::result;
  244. // Utility: smallest unsigned integer type that can store n-bit value
  245. template<unsigned bits>
  246. using SmallestType = std::conditional_t< (bits<=16),
  247. std::conditional_t< (bits<= 8), std::uint_least8_t, std::uint_least16_t>,
  248. std::conditional_t< (bits<=32), std::uint_least32_t, std::uint_least64_t>>;
  249. // testcases
  250. static_assert(FloorLog2<1> == 0, "FloorLog2 fail"); static_assert(CeilLog2<1> == 0, "CeilLog2 fail");
  251. static_assert(FloorLog2<2> == 1, "FloorLog2 fail"); static_assert(CeilLog2<2> == 1, "CeilLog2 fail");
  252. static_assert(FloorLog2<3> == 1, "FloorLog2 fail"); static_assert(CeilLog2<3> == 2, "CeilLog2 fail");
  253. static_assert(FloorLog2<4> == 2, "FloorLog2 fail"); static_assert(CeilLog2<4> == 2, "CeilLog2 fail");
  254. static_assert(FloorLog2<5> == 2, "FloorLog2 fail"); static_assert(CeilLog2<5> == 3, "CeilLog2 fail");
  255. static_assert(FloorLog2<6> == 2, "FloorLog2 fail"); static_assert(CeilLog2<6> == 3, "CeilLog2 fail");
  256. static_assert(FloorLog2<7> == 2, "FloorLog2 fail"); static_assert(CeilLog2<7> == 3, "CeilLog2 fail");
  257. static_assert(FloorLog2<8> == 3, "FloorLog2 fail"); static_assert(CeilLog2<8> == 3, "CeilLog2 fail");
  258. static_assert(FloorLog2<9> == 3, "FloorLog2 fail"); static_assert(CeilLog2<9> == 4, "CeilLog2 fail");
  259. template<bool packed, unsigned Dimension, unsigned ElementSize>
  260. struct RandomAccessArray {};
  261. template<unsigned Dim, unsigned Elem>
  262. struct RandomAccessArray<true, Dim, Elem>
  263. {
  264. RandomAccessBitArray<Dim*Elem> impl;
  265. inline std::uint_fast64_t Get(unsigned index) const { return impl.template Get<Elem>(index); }
  266. inline void Set(unsigned index, std::uint_fast32_t value) { impl.template Set<Elem,true>(index, value); }
  267. inline void QSet(unsigned index, std::uint_fast32_t value) { impl.template Set<Elem,false>(index, value); }
  268. template<unsigned Bits>
  269. inline void WSet(unsigned index, std::uint_fast64_t value) { impl.template Set<Bits,true>(index, value); }
  270. };
  271. template<unsigned Dim, unsigned Elem>
  272. struct RandomAccessArray<false, Dim, Elem>
  273. {
  274. typedef SmallestType<Elem> E;
  275. E data[Dim];
  276. inline E Get(unsigned index) const { return data[index]; }
  277. inline void Set(unsigned index, E value) { data[index] = value; }
  278. inline void QSet(unsigned index, E value) { data[index] = value; }
  279. template<unsigned Bits>
  280. inline void WSet(unsigned index, std::uint_fast64_t value)
  281. {
  282. index *= Bits/Elem;
  283. for(unsigned b=0; b<Bits; b+=Elem, value>>=Elem)
  284. QSet(index++, (value % (1u << Elem)));
  285. }
  286. };
  287. }
  288. namespace gunzip_ns
  289. {
  290. //#define DEFL_DO_HUFF_STATS
  291. template<bool Abortable, unsigned A,unsigned B, typename LengthFunctor>
  292. bool CreateHuffmanTree(const char*
  293. #ifdef DEFL_DO_HUFF_STATS
  294. why
  295. #endif
  296. , RandomAccessArray<USE_BITARRAY_FOR_HUFFNODES,A,B>& tree,
  297. unsigned num_values,
  298. LengthFunctor&& ReadLength) throw()
  299. {
  300. /* Lengths[] needs to be scanned exactly twice, in forward order.
  301. * Technically we could use a functor instead of a table,
  302. * but this would require that the dynamic tree generator
  303. * can read sections of the compressed data twice,
  304. * which we currently do not support.
  305. */
  306. constexpr unsigned ElemBits = CeilLog2<A-15>; // ceil(log2(A-15)) where A-15 is max value of num_values
  307. static_assert((1u << B) >= (A-15), "B is too small");
  308. assert(num_values <= (A-15));
  309. RandomAccessArray<USE_BITARRAY_TEMPORARY_IN_HUFFMAN_CREATION, 15, ElemBits> offs{}; // 24 or 16 bytes.
  310. // Theoretically 15.32 bytes for 288 num_values, 9.375 for 32 num_values, 7.97 for 19 num_values.
  311. // Clear code length count table
  312. tree.template WSet<(15*B + 63) & ~63>(0, 0); // First 15 needed, but round to nice unit
  313. // Scan symbol length, and sum code length counts
  314. #ifdef DEFL_DO_HUFF_STATS
  315. unsigned largest_treetable_value = 0, largest_offs = 0, smallest_treetable_value = ~0u;
  316. unsigned largest_treetrans_index=0, largest_treetrans_value=0;
  317. unsigned longest_length = 0;
  318. #endif
  319. for(unsigned a = 0; a < num_values; ++a)
  320. {
  321. int length = ReadLength(a); // Note: Can be zero.
  322. if(Abortable && length < 0) return true;
  323. if(length)
  324. {
  325. unsigned v = tree.Get(0 + length-1)+1;
  326. #ifdef DEFL_DO_HUFF_STATS
  327. largest_treetable_value = std::max(largest_treetable_value, v);
  328. longest_length = std::max(longest_length, unsigned(length));
  329. #endif
  330. tree.Set(0 + length-1, v);
  331. }
  332. }
  333. // Compute offset table for distribution sort
  334. for(unsigned sum=0, a = 1; a < 16; ++a)
  335. {
  336. offs.QSet(a-1, sum); // starting offset for values that have length "a"
  337. sum += tree.Get(0 + a-1); // number of values that have length "a"
  338. }
  339. #ifdef DEFL_DO_HUFF_STATS
  340. for(unsigned a=1; a<=longest_length; ++a)
  341. smallest_treetable_value = std::min(smallest_treetable_value, (unsigned)tree.Get(0 + a-1));
  342. #endif
  343. // Create code->symbol translation table (symbols sorted by code)
  344. for(unsigned value = 0; value < num_values; ++value)
  345. {
  346. int length = ReadLength(value); // Note: Can be zero.
  347. if(Abortable && length < 0) return true;
  348. if(length)
  349. {
  350. unsigned q = offs.Get(length-1); offs.Set(length-1, q+1); // q = offset[length]++;
  351. #ifdef DEFL_DO_HUFF_STATS
  352. largest_offs = std::max(q, largest_offs);
  353. largest_treetrans_index = std::max(largest_treetrans_index, q);
  354. largest_treetrans_value = std::max(largest_treetrans_value, value);
  355. #endif
  356. assert(q < num_values /*&& value < num_values*/);
  357. tree.Set(15 + q, value);
  358. }
  359. }
  360. #ifdef DEFL_DO_HUFF_STATS
  361. std::fprintf(stderr, "Largest \"%12s\"(treetable_value=%4u..%4u, offs=%4u, treetrans_index=%4u, treetrans_value=%4u)\n",
  362. why, smallest_treetable_value,largest_treetable_value,
  363. largest_offs, largest_treetrans_index, largest_treetrans_value);
  364. #endif
  365. // Largest values observed in the wild:
  366. // Dyn Lengths: Max treetable_value =255, max offs =285, max treetrans_index =285, max treetrans_value =285
  367. // Stat Lengths:Max treetable_value =152, max offs =287, max treetrans_index =287, max treetrans_value =287
  368. // Len Lengths: Max treetable_value = 13, max offs = 18, max treetrans_index = 18, max treetrans_value = 18
  369. // Dyn Dists: Max treetable_value = 19, max offs = 29, max treetrans_index = 29, max treetrans_value = 29
  370. // Stat Dists: Max treetable_value = 32, max offs = 31, max treetrans_index = 31, max treetrans_value = 31
  371. return false;
  372. }
  373. #ifdef DEFLATE_USE_DATA_TABLES
  374. template<bool=0> // Using a dummy template parameter makes this function and its data weak,
  375. inline const std::uint_least8_t* GetBTable() throw() // removing linker problems in multi-module use
  376. {
  377. static const std::uint_least8_t data[] {
  378. // Length bases (0-31)
  379. 0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224,255, 0,0,0,
  380. // Length bits and distance bits (29-60) (overlap 3 bytes)
  381. // 0x00,0x01,0x01,0x02,0x02,0x13,0x13,0x14,0x14,0x25,0x25,0x26,0x26,
  382. //0x37,0x37,0x38,0x38,0x49,0x49,0x4A,0x4A,0x5B,0x5B,0x5C,0x5C,0x0D,0x0D,0x00,0x00
  383. // Reverse-order table
  384. 3*3,17*3,15*3,13*3,11*3,9*3,7*3,5*3,4*3,6*3,8*3,10*3,12*3,14*3,16*3,18*3,0*3,1*3,2*3
  385. };
  386. return data;
  387. }
  388. //template<bool=0>
  389. //inline const std::uint_least16_t* GetWTable() throw()
  390. //{
  391. // static const std::uint_least16_t data[32] {
  392. // 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577, 0,0 };
  393. // return data;
  394. //}
  395. //inline unsigned dbase(unsigned distcode) { return GetWTable<>()[distcode]; }
  396. inline unsigned lbase(unsigned lencode) { return GetBTable<>()[lencode-257+0] + 3; }
  397. //inline unsigned dbits(unsigned distcode) { return GetBTable<>()[distcode+29] & 0xF; }
  398. //inline unsigned lbits(unsigned lencode) { return GetBTable<>()[lencode-257+29] >> 4; }
  399. inline unsigned rshift(unsigned a) { return GetBTable<>()[a + 32]; }
  400. #else
  401. inline unsigned lbase(unsigned lencode) { return (lencode > 285 ? 3 : ((lencode >= 265) ? (((lencode-257)%4+4) << ((lencode-257)/4-1)) + (lencode==285 ? 2 : 3) : (lencode-254))); }
  402. inline unsigned rshift(unsigned a) { if(!a) return 3*3; else if(a>=16) return (a-16)*3; int r = 12 + 7*(a<8) - a*2; return (r<0 ? -r : r)*3; }
  403. #endif
  404. inline unsigned dbase(unsigned distcode) { return (1 + (distcode>=4 ? ((2+distcode%2) << (distcode/2-1)) : distcode)); }
  405. inline unsigned dbits(unsigned distcode) { return distcode>=4 ? distcode/2-1 : 0; }
  406. inline unsigned lbits(unsigned lencode) { return ((lencode>=265 && lencode<285) ? ((lencode-265)/4+1) : 0); }
  407. //inline unsigned order(unsigned index) { return index<3 ? (index+16) : ((index%2) ? (1-index/2)&7 : (6+index/2)); }
  408. // Cortex-M0+ Cortex-M4 x86_64
  409. // dbase with table 12+64 = 76 12+64 = 76 14+64 = 78
  410. // dbase with func 24 22 26
  411. // lbase with table 12+32 = 48 12+32 = 48 21+64 = 76
  412. // lbase with func 54 56 64
  413. // dbits+lbits with table 12+16+29 = 57 12+16+29 = 57 17+21+29 = 67
  414. // dbits+lbits with func 14+18 = 32 14+18 = 32 13+20 = 33
  415. template<bool Abortable>
  416. struct OutputHelper
  417. {
  418. template<typename OutputFunctor>
  419. static inline bool output(OutputFunctor&& output, unsigned char byte)
  420. {
  421. output(byte);
  422. return false;
  423. }
  424. template<typename WindowFunctor>
  425. static inline bool outputcopy(WindowFunctor&& outputcopy, std::uint_least16_t length, std::uint_fast32_t offset)
  426. {
  427. outputcopy(length, offset);
  428. return false;
  429. }
  430. };
  431. template<>
  432. struct OutputHelper<true>
  433. {
  434. template<typename OutputFunctor>
  435. static inline bool output(OutputFunctor&& output, unsigned char byte)
  436. {
  437. return output(byte);
  438. }
  439. template<typename WindowFunctor>
  440. static inline bool outputcopy(WindowFunctor&& outputcopy, std::uint_least16_t& length, std::uint_fast32_t offset)
  441. {
  442. length = outputcopy(length, offset);
  443. return length != 0;
  444. }
  445. };
  446. struct SizeTracker_NoOutput
  447. {
  448. inline void OutByte() { }
  449. inline void OutBytes(std::uint_fast64_t) { }
  450. // Dummy forwarders. Do the same as std::forward.
  451. template<typename T>
  452. static inline constexpr T&& ForwardOutput(std::remove_reference_t<T>& fun) { return static_cast<T&&>(fun); }
  453. template<typename T>
  454. static inline constexpr T&& ForwardOutput(std::remove_reference_t<T>&& fun) { return static_cast<T&&>(fun); }
  455. template<typename T>
  456. static inline constexpr T&& ForwardWindow(std::remove_reference_t<T>& fun) { return static_cast<T&&>(fun); }
  457. template<typename T>
  458. static inline constexpr T&& ForwardWindow(std::remove_reference_t<T>&& fun) { return static_cast<T&&>(fun); }
  459. };
  460. struct SizeTracker_NoInput
  461. {
  462. inline void InByte() { }
  463. inline void InBytes(std::uint_fast64_t) { }
  464. template<typename T>
  465. static inline constexpr T&& ForwardInput(std::remove_reference_t<T>& fun) { return static_cast<T&&>(fun); }
  466. template<typename T>
  467. static inline constexpr T&& ForwardInput(std::remove_reference_t<T>&& fun) { return static_cast<T&&>(fun); }
  468. };
  469. struct SizeTracker_DoInput
  470. {
  471. std::uint_fast64_t insize=0;
  472. inline void InByte() { ++insize; }
  473. inline void InBytes(std::uint_fast64_t n) { insize += n; }
  474. template<typename InputFunctor, std::enable_if_t<!DeflInputAbortable_InputFunctor,gunzip_ns::dummy>...>
  475. auto ForwardInput(const InputFunctor& input)
  476. {
  477. return [&]() { InByte(); return input(); };
  478. }
  479. template<typename InputFunctor, std::enable_if_t<DeflInputAbortable_InputFunctor,gunzip_ns::dummy>...>
  480. auto ForwardInput(const InputFunctor& input)
  481. {
  482. return [&]() { auto r = input(); if(!(r & ~0xFF)) { InByte(); } return r; };
  483. }
  484. };
  485. struct SizeTracker_DoOutput
  486. {
  487. std::uint_fast64_t outsize=0;
  488. inline void OutByte() { ++outsize; }
  489. inline void OutBytes(std::uint_fast64_t n) { outsize += n; }
  490. template<typename OutputFunctor, std::enable_if_t<!DeflOutputAbortable_OutputFunctor,gunzip_ns::dummy>...>
  491. auto ForwardOutput(const OutputFunctor& output)
  492. {
  493. return [&](unsigned char byte) { OutByte(); return output(byte); };
  494. }
  495. template<typename OutputFunctor, std::enable_if_t<DeflOutputAbortable_OutputFunctor,gunzip_ns::dummy>...>
  496. auto ForwardOutput(const OutputFunctor& output)
  497. {
  498. return [&](unsigned char byte) { auto r = output(byte); if(!r) { OutByte(); } return r; };
  499. }
  500. template<typename WindowFunctor, std::enable_if_t<!DeflOutputAbortable_WindowFunctor,gunzip_ns::dummy>...>
  501. auto ForwardWindow(const WindowFunctor& outputcopy)
  502. {
  503. return [&](std::uint_least16_t length, std::uint_fast32_t offset)
  504. {
  505. OutBytes(length);
  506. return outputcopy(length, offset);
  507. };
  508. }
  509. template<typename WindowFunctor, std::enable_if_t<DeflOutputAbortable_WindowFunctor,gunzip_ns::dummy>...>
  510. auto ForwardWindow(const WindowFunctor& outputcopy)
  511. {
  512. return [&](std::uint_least16_t length, std::uint_fast32_t offset)
  513. {
  514. auto remain = outputcopy(length, offset);
  515. OutBytes(length - remain);
  516. return remain;
  517. };
  518. }
  519. };
  520. template<typename TrackType>
  521. struct SizeTracker: public SizeTracker_NoOutput, public SizeTracker_NoInput
  522. {
  523. inline int operator() (int returncode) const { return returncode; }
  524. };
  525. template<>
  526. struct SizeTracker<DeflateTrackOutSize>: public SizeTracker_NoInput, public SizeTracker_DoOutput
  527. {
  528. typedef std::pair<int,std::uint_fast64_t> result;
  529. inline result operator() (int returncode) const { return result{returncode,outsize}; }
  530. };
  531. template<>
  532. struct SizeTracker<DeflateTrackInSize>: public SizeTracker_NoOutput, public SizeTracker_DoInput
  533. {
  534. typedef std::pair<int,std::uint_fast64_t> result;
  535. inline result operator() (int returncode) const { return result{returncode,insize}; }
  536. };
  537. template<>
  538. struct SizeTracker<DeflateTrackBothSize>: public SizeTracker_DoInput, public SizeTracker_DoOutput
  539. {
  540. typedef std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>> result;
  541. inline result operator() (int returncode) const { return result{returncode,std::make_pair(insize,outsize)}; }
  542. };
  543. struct DeflateBitCache
  544. {
  545. std::uint_least8_t BitCache = 0, BitCount = 0;
  546. template<bool Abortable, typename InputFunctor>
  547. std::uint_least64_t GetBits(InputFunctor&& input, unsigned numbits)
  548. {
  549. std::uint_fast64_t result = BitCache;
  550. if(numbits <= BitCount)
  551. {
  552. BitCount -= numbits;
  553. BitCache >>= numbits;
  554. result &= ((1u << numbits)-1); // 0-8
  555. return result;
  556. }
  557. for(unsigned acquired = BitCount; ; acquired += 8)
  558. {
  559. unsigned byte = input();
  560. if(Abortable && (byte & ~0xFFu))
  561. {
  562. // Note: Throws away bits already eaten from BitCache
  563. return ~std::uint_least64_t(0); // error
  564. }
  565. unsigned eat = numbits-acquired;
  566. byte &= 0xFF;
  567. if(eat <= 8)
  568. {
  569. result |= ((std::uint_fast64_t)(byte & ((1u << eat)-1))) << acquired;
  570. BitCount = 8-eat;
  571. BitCache = byte >> eat;
  572. return result;
  573. }
  574. result |= ((std::uint_fast64_t)(byte)) << acquired;
  575. }
  576. }
  577. template<bool Abortable, typename InputFunctor, unsigned A,unsigned B>
  578. std::uint_least32_t HuffRead(InputFunctor&& input,
  579. RandomAccessArray<USE_BITARRAY_FOR_HUFFNODES,A,B>& tree)
  580. {
  581. int sum=0, cur=0, len=0;
  582. #ifdef DEFL_DO_HUFF_STATS
  583. static int maxlen = 0;
  584. #endif
  585. // Get more bits while code value is above sum
  586. do {
  587. auto p = GetBits<Abortable>(std::forward<InputFunctor>(input), 1);
  588. if(Abortable && !~p)
  589. {
  590. // Note: Throws away progress already made traversing the tree
  591. return ~std::uint_least32_t(0); // error flag
  592. }
  593. cur = (unsigned(cur) << 1) | bool(p);
  594. #ifdef DEFL_DO_HUFF_STATS
  595. if(len > maxlen)
  596. {
  597. maxlen = len;
  598. std::fprintf(stderr, "maxlen access: %d (%d)\n", maxlen, (int)tree.Get(0 + len));
  599. }
  600. #endif
  601. auto v = tree.Get(0 + len++);
  602. sum += v;
  603. cur -= v;
  604. } while(cur >= 0);
  605. return tree.Get(15 + sum + cur);
  606. }
  607. };
  608. template<bool Backtrackable>
  609. struct DeflateState: public DeflateBitCache
  610. {
  611. std::uint_least8_t lencode = 0, num = 0; // used in DynTreeFunc
  612. // Lengths are in 0..15 range.
  613. RandomAccessArray<USE_BITARRAY_FOR_LENGTHS, 288, CeilLog2<16>> Lengths; // 144 bytes
  614. // Length tree
  615. // Values up to 288 in indexes 0-14. (Table) (255 is max observed in wild)
  616. // Values up to 287 in indexes 15-302. (Trans)
  617. RandomAccessArray<USE_BITARRAY_FOR_HUFFNODES, 15+288, CeilLog2<289>> ltree; // 341->344 bytes
  618. // Distance tree
  619. // Values up to 32 in indexes 0-14. (Table)
  620. // Values up to 31 in indexes 15-46. (Trans)
  621. RandomAccessArray<USE_BITARRAY_FOR_HUFFNODES, 15+32, CeilLog2<33>> dtree; // 36->40 bytes
  622. RandomAccessArray<USE_BITARRAY_FOR_HUFFNODES, 15+32, CeilLog2<33>>& lltree = dtree;
  623. // Theoretical minimum memory use:
  624. // (15*log2(289) + 288*log2(288))/8 = 309.45 bytes for ltree
  625. // (15*log2(33) + 32 *log2(32))/8 = 29.46 bytes for dtree
  626. // 144.00 bytes for lengths
  627. // total 482.91 bytes
  628. template<bool Abortable, typename InputFunctor, typename BacktrackFunctor>
  629. auto DynTreeFunc(InputFunctor&& input, std::uint_fast16_t length, BacktrackFunctor&&)
  630. {
  631. Lengths = {}; // clear at least length nibbles; easiest to clear it all
  632. bool error = false;
  633. for(std::uint_fast16_t code = 0; ; )
  634. {
  635. if(!num)
  636. {
  637. auto p = HuffRead<Abortable>(std::forward<InputFunctor>(input), lltree);
  638. if(Abortable && !~p) { error = true; goto done; }
  639. std::uint_least8_t what = p; // 0-18
  640. if(!(what & 16)) { lencode = what * 0x11u; what = 0x01; } // 1 times (what < 16) (use what, set prev)
  641. else if(what < 17) { lencode = (lencode >> 4) * 0x11u; what = 0x23; } // 3..6 (use prev)
  642. else if(what == 17) { lencode &= 0xF0; what = 0x33; } // 3..10 (use 0)
  643. else { lencode &= 0xF0; what = 0x7B; } // 11..138 (use 0)
  644. p = GetBits<Abortable>(std::forward<InputFunctor>(input), what >> 4); // 0, 2, 3 or 7 bits
  645. if(Abortable && !~p) { error = true; goto done; }
  646. num = p + (what & 0xF); // 1..138
  647. }
  648. do {
  649. --num;
  650. Lengths.QSet(code++, lencode & 0xF);
  651. if(code == length) { goto done; }
  652. } while(num > 0);
  653. }
  654. done:;
  655. return [this,error](unsigned index) -> std::conditional_t<Abortable, int, unsigned char>
  656. {
  657. if(Abortable && error) return -1;
  658. return Lengths.Get(index);
  659. };
  660. }
  661. };
  662. template<>
  663. struct DeflateState<true>: public DeflateBitCache
  664. {
  665. // Length tree
  666. // Values up to 288 in indexes 0-14. (Table) (255 is max observed in wild)
  667. // Values up to 287 in indexes 15-302. (Trans)
  668. RandomAccessArray<USE_BITARRAY_FOR_HUFFNODES, 15+288, CeilLog2<289>> ltree; // 341->344 bytes
  669. // Distance tree
  670. // Values up to 32 in indexes 0-14. (Table)
  671. // Values up to 31 in indexes 15-46. (Trans)
  672. RandomAccessArray<USE_BITARRAY_FOR_HUFFNODES, 15+32, CeilLog2<33>> dtree; // 36->40 bytes
  673. // Length-lengths tree
  674. // Values up to 19 in indexes 0-14. (Table) (13 is max observed in wild)
  675. // Values up to 18 in indexes 15-33. (Trans)
  676. RandomAccessArray<USE_BITARRAY_FOR_HUFFNODES, 15+19, CeilLog2<20>> lltree; // 22->24 bytes
  677. // Theoretical minimum memory use:
  678. // (15*log2(289) + 288*log2(288))/8 = 309.45 bytes for ltree
  679. // (15*log2(33) + 32 *log2(32))/8 = 29.46 bytes for dtree
  680. // (15*log2(20) + 19 *log2(19))/8 = 18.19 bytes for lltree
  681. // total 357.10 bytes
  682. std::uint_least8_t lencode, num; // used in DynTreeFunc
  683. std::uint_least8_t checkpoint_lencode, checkpoint_num;
  684. std::uint_least8_t checkpoint_BitCache, checkpoint_BitCount;
  685. template<bool Abortable, typename InputFunctor, typename BacktrackFunctor>
  686. auto DynTreeFunc(InputFunctor&& input, std::uint_fast16_t length, BacktrackFunctor&& backtrack)
  687. {
  688. // Create checkpoint
  689. checkpoint_lencode = 0;
  690. checkpoint_num = 0;
  691. checkpoint_BitCache = BitCache;
  692. checkpoint_BitCount = BitCount;
  693. backtrack(false);
  694. return [&](unsigned index) -> std::conditional_t<Abortable, int, unsigned char>
  695. {
  696. if(index == 0)
  697. {
  698. // Restore checkpoint
  699. lencode = checkpoint_lencode;
  700. num = checkpoint_num;
  701. BitCache = checkpoint_BitCache;
  702. BitCount = checkpoint_BitCount;
  703. backtrack(true);
  704. }
  705. if(Abortable && (num==0xFF)) return -1;
  706. if(!num)
  707. {
  708. auto p = HuffRead<Abortable>(std::forward<InputFunctor>(input), lltree);
  709. if(Abortable && !~p) { num = 0xFF; return -1; }
  710. std::uint_least8_t what = p; // 0-18
  711. if(!(what & 16)) { lencode = what * 0x11u; what = 0x01; } // 1 times (what < 16) (use what, set prev)
  712. else if(what < 17) { lencode = (lencode >> 4) * 0x11u; what = 0x23; } // 3..6 (use prev)
  713. else if(what == 17) { lencode &= 0xF0; what = 0x33; } // 3..10 (use 0)
  714. else { lencode &= 0xF0; what = 0x7B; } // 11..138 (use 0)
  715. p = GetBits<Abortable>(std::forward<InputFunctor>(input), what >> 4); // 0, 2, 3 or 7 bits
  716. if(Abortable && !~p) { num = 0xFF; return -1; }
  717. num = p + (what & 0xF); // 1..138
  718. }
  719. --num;
  720. return (lencode & 0xF);
  721. };
  722. }
  723. };
  724. struct DeflateWindow
  725. {
  726. unsigned char Data[gunzip_ns::MAX_WINDOW_SIZE];
  727. SmallestType<CeilLog2<gunzip_ns::MAX_WINDOW_SIZE>> Head = 0;
  728. };
  729. #ifdef DEFLATE_ALLOCATION_STATIC
  730. template<typename ObjectType>
  731. ObjectType& GetStaticObj()
  732. {
  733. static thread_local ObjectType obj;
  734. obj.~ObjectType();
  735. new(&obj) ObjectType();
  736. return obj;
  737. }
  738. #endif
  739. /* Values of Abortable:
  740. *
  741. * Input abortable Output abortable Resumable Value
  742. * no no no 0
  743. * yes no no 1
  744. * no yes no 2
  745. * yes yes no 3
  746. * 4 = invalid
  747. * yes no yes 5
  748. * no yes yes 6
  749. * yes yes yes 7
  750. */
  751. template<unsigned char Abortable,
  752. typename InputFunctor, typename OutputFunctor, typename WindowFunctor,
  753. typename BacktrackFunctor>
  754. int Gunzip(InputFunctor&& input,
  755. OutputFunctor&& output,
  756. WindowFunctor&& outputcopy,
  757. BacktrackFunctor&& backtrack)
  758. {
  759. using namespace gunzip_ns;
  760. typedef DeflateState<!std::is_same<std::decay_t<BacktrackFunctor>,dummy>::value> StateType;
  761. #ifdef DEFLATE_ALLOCATION_AUTOMATIC
  762. StateType state;
  763. #elif defined(DEFLATE_ALLOCATION_STATIC)
  764. auto& state = gunzip_ns::GetStaticObj<StateType>();
  765. #elif defined(DEFLATE_ALLOCATION_DYNAMIC)
  766. std::unique_ptr<StateType> stateptr(new StateType);
  767. auto& state = *stateptr;
  768. #endif
  769. // The following routines are macros rather than e.g. lambda functions,
  770. // in order to make them inlined in the function structure, and breakable/resumable.
  771. // Bit-by-bit input routine
  772. #define DummyGetBits(numbits) do { \
  773. auto p = state.template GetBits<bool(Abortable&1)>(std::forward<InputFunctor>(input), numbits); \
  774. if((Abortable & 1) && !~p) return -2; \
  775. } while(0)
  776. #define GetBits(numbits, target) \
  777. auto p = state.template GetBits<bool(Abortable&1)>(std::forward<InputFunctor>(input), numbits); \
  778. if((Abortable & 1) && !~p) return -2; \
  779. target = p
  780. // Huffman tree read routine.
  781. #define HuffRead(tree, target) \
  782. auto p = state.template HuffRead<bool(Abortable&1)>(std::forward<InputFunctor>(input), tree); \
  783. if((Abortable & 1) && !~p) return -2; \
  784. target = p
  785. #define Fail_If(condition) do { \
  786. /*assert(!(condition));*/ \
  787. if(condition) return -1; \
  788. } while(0)
  789. // Read stream header
  790. GetBits(16, std::uint_least16_t header);
  791. // ^ Read deflate header: method[4] ; winsize[4] ; checksum[8]
  792. if(header == 0x8B1F) // Is it actually a gzip header?
  793. {
  794. // Get format identifier, flags, MTIME, XFL and OS
  795. GetBits(64, header); Fail_If((header & 0xFF) != 8); // Format identifier should be 8
  796. if(header&0x0400) // Skip extra fields as indicated by FEXTRA
  797. { GetBits(16, std::uint_fast16_t q); DummyGetBits(8*q); }
  798. if(header&0x0800) for(;;) { GetBits(8, bool q); if(!q) break; } // NAME: Skip filename if FNAME was present
  799. if(header&0x1000) for(;;) { GetBits(8, bool q); if(!q) break; } // COMMENT: Skip comment if FCOMMENT was present
  800. if(header&0x0200) { DummyGetBits(16); } // HCRC: Skip FCRC if was present
  801. outputcopy(0, 32768u); // GZIP always uses 32k window
  802. }
  803. else // No. Deflate header?
  804. {
  805. Fail_If((header & 0x208F) != 0x0008 || ((((header<<8)+(header>>8))&0xFFFF)%31) != 0);
  806. outputcopy(0, 256 << ((header >> 4) & 0xF)); // Preset dictionary (0x2000) is not supported
  807. }
  808. // Read compressed blocks
  809. for(;;)
  810. {
  811. GetBits(3, header);
  812. if(header & 4) // Dynamic block
  813. {
  814. Fail_If(header & 2);
  815. std::uint_least16_t nlen_ndist_ncode;
  816. GetBits(14, nlen_ndist_ncode);
  817. #define nlen (((nlen_ndist_ncode >> 0u) & 0x1Fu) + 257u) // 257..288
  818. #define ndist (((nlen_ndist_ncode >> 5u) & 0x1Fu) + 1u) // 1..32
  819. std::uint_least8_t ncode = ((nlen_ndist_ncode >> 10u) + 4u); // 4..19
  820. {std::uint_fast64_t lenlens; GetBits(ncode*3, lenlens); // Max: 19*3 = 57 bits
  821. auto lltree_fun = [=](unsigned a) -> unsigned char { return (lenlens >> rshift(a)) & 7; };
  822. while(CreateHuffmanTree<bool(Abortable&1)>("Len Lengths", state.lltree, 19, lltree_fun)) { return -2; }}
  823. {auto ltree_fun = state.template DynTreeFunc<bool(Abortable&1)>(std::forward<InputFunctor>(input), nlen, std::forward<BacktrackFunctor>(backtrack));
  824. while(CreateHuffmanTree<bool(Abortable&1)>("Dyn Lengths", state.ltree, nlen, ltree_fun)) { return -2; }}
  825. {auto dtree_fun = state.template DynTreeFunc<bool(Abortable&1)>(std::forward<InputFunctor>(input), ndist, std::forward<BacktrackFunctor>(backtrack));
  826. while(CreateHuffmanTree<bool(Abortable&1)>("Dyn Dists", state.dtree, ndist, dtree_fun)) { return -2; }}
  827. #undef nlen
  828. #undef ndist
  829. }
  830. else // Fixed block
  831. {
  832. if(header < 2) // Copy stored block data
  833. {
  834. DummyGetBits(state.BitCount%8); // Go to byte boundary (discard a few bits)
  835. GetBits(32, std::uint_least32_t a);
  836. Fail_If(((a ^ (a >> 16)) & 0xFFFF) != 0xFFFF);
  837. // Note: It is valid for (lower 16 bits of) "a" to be 0 here.
  838. // It is sometimes used for aligning the stream to byte boundary.
  839. while(a-- & 0xFFFF)
  840. {
  841. GetBits(8, unsigned char octet);
  842. while(OutputHelper<bool(Abortable&2)>::output(output, octet)) { return -3; }
  843. }
  844. goto skipdef;
  845. }
  846. unsigned char (*ltree_fun)(unsigned) = [](unsigned n)->unsigned char{return (n<0x90 || n>=0x118) ? 8u : (n<0x100 ? 9u : 7u); };
  847. unsigned char (*dtree_fun)(unsigned) = [](unsigned )->unsigned char{return 5u;};
  848. while(CreateHuffmanTree<false>("Stat Lengths", state.ltree, 288, ltree_fun)) { return -2; }
  849. while(CreateHuffmanTree<false>("Stat Dists", state.dtree, 32, dtree_fun)) { return -2; }
  850. }
  851. // Do actual deflating.
  852. for(;;)
  853. {
  854. HuffRead(state.ltree, std::uint_least16_t lencode); // 0..287
  855. if(!(lencode & -256)) // 0..255: literal byte
  856. {
  857. while(OutputHelper<bool(Abortable&2)>::output(output, lencode)) { return -3; }
  858. }
  859. else if(!(lencode & 0xFF)) break; // 256=end
  860. else // 257..287: length code for backwards reference
  861. {
  862. GetBits(lbits(lencode), std::uint_least16_t length); length += lbase(lencode);
  863. {HuffRead(state.dtree, std::uint_least8_t distcode); // Read distance code (0..31)
  864. {GetBits(dbits(distcode), std::uint_least32_t offset); offset += dbase(distcode);
  865. while(OutputHelper<bool(Abortable&2)>::outputcopy(outputcopy,length,offset)) { return -4; }}}
  866. }
  867. }
  868. skipdef:if(header & 1) break; // last block flag
  869. }
  870. // Note: after this, may come a checksum, and a trailer. Ignoring them.
  871. #undef GetBits
  872. #undef DummyGetBits
  873. #undef Fail_If
  874. #undef HuffRead
  875. return 0;
  876. }
  877. }//ns
  878. #ifdef DEFLATE_ALLOCATION_AUTOMATIC
  879. #define DeflDeclWindow gunzip_ns::DeflateWindow window;
  880. #elif defined(DEFLATE_ALLOCATION_STATIC)
  881. #define DeflDeclWindow auto& window = gunzip_ns::GetStaticObj<gunzip_ns::DeflateWindow>();
  882. #elif defined(DEFLATE_ALLOCATION_DYNAMIC)
  883. #define DeflDeclWindow std::unique_ptr<gunzip_ns::DeflateWindow> winptr(new gunzip_ns::DeflateWindow); \
  884. auto& window = *winptr;
  885. #endif
  886. #define DEFL_MACRO_Inf \
  887. gunzip_ns::dummy btfun{};
  888. #define DEFL_MACRO_InI \
  889. auto inputfun = [&]() { auto r = *input; ++input; return r; }; \
  890. gunzip_ns::dummy btfun{};
  891. #define DEFL_MACRO_InI2 \
  892. auto inputfun = [&]() { if(begin==end) { return -1; } int r = *begin; ++begin; return r; }; \
  893. gunzip_ns::dummy btfun{};
  894. #define DEFL_MACRO_InIl \
  895. typename std::iterator_traits<std::decay_t<InputIterator>>::difference_type remain(length); \
  896. auto inputfun = [&]() -> std::common_type_t<int, decltype(*begin)> \
  897. { if(!remain) { return -1; } --remain; int r = *begin; ++begin; return r; }; \
  898. gunzip_ns::dummy btfun{};
  899. #define DEFL_MACRO_InBl \
  900. typename std::iterator_traits<std::decay_t<BidirIterator>>::difference_type remain(length), savestate{}; \
  901. auto inputfun = [&]() -> std::common_type_t<int, decltype(*begin)> \
  902. { if(!remain) { return -1; } --remain; int r = *begin; ++begin; return r; }; \
  903. auto btfun = [&](bool act) { if(act) { begin -= (savestate-remain); remain = savestate; } else savestate = remain; };
  904. #define DEFL_MACRO_InF \
  905. ForwardIterator saved;auto inputfun = [&]() { auto r = *begin; ++begin; return r; }; \
  906. auto btfun = [&](bool act) { if(act) begin = saved; else saved = std::move(begin); };
  907. #define DEFL_MACRO_InF2 \
  908. ForwardIterator saved; \
  909. auto inputfun = [&]() { if(begin==end) { return -1; } int r = *begin; ++begin; return r; }; \
  910. auto btfun = [&](bool act) { if(act) begin = saved; else saved = std::move(begin); };
  911. #define DEFL_MACRO_Outf \
  912. DeflDeclWindow \
  913. auto output = [&](unsigned char l) \
  914. { \
  915. window.Data[window.Head++ % gunzip_ns::MAX_WINDOW_SIZE] = l; \
  916. return output_orig(l); \
  917. }; \
  918. auto outputcopy = [&](std::uint_least16_t length, std::uint_fast32_t offs) \
  919. { \
  920. /* length=0 means that offs is the size of the window. */ \
  921. for(; length>0; --length) \
  922. { \
  923. unsigned char byte = window.Data[(window.Head - offs) % gunzip_ns::MAX_WINDOW_SIZE]; \
  924. if(gunzip_ns::OutputHelper<bool(Abortable&2)>::output(output, byte)) \
  925. break; \
  926. } \
  927. return length; \
  928. };
  929. #define DEFL_MACRO_OutI \
  930. DeflDeclWindow \
  931. auto output = [&](unsigned char l) \
  932. { \
  933. window.Data[window.Head++ % gunzip_ns::MAX_WINDOW_SIZE] = l; \
  934. *target = l; ++target; \
  935. }; \
  936. auto outputcopy = [&](std::uint_least16_t length, std::uint_fast32_t offs) \
  937. { \
  938. /* length=0 means that offs is the size of the window. */ \
  939. for(; length>0; --length) \
  940. { \
  941. unsigned char byte = window.Data[(window.Head - offs) % gunzip_ns::MAX_WINDOW_SIZE]; \
  942. output(byte); \
  943. } \
  944. return false; \
  945. };
  946. #define DEFL_MACRO_Outr \
  947. auto output = [&](unsigned char l) { *target = l; ++target; }; \
  948. auto outputcopy = [&](std::uint_least16_t length, std::uint_fast32_t offs) \
  949. { \
  950. /* length=0 means that offs is the size of the window. */ \
  951. for(; length--; ++target) { *target = *(target-offs); } \
  952. };
  953. #define DEFL_MACRO_Outrl \
  954. typename std::iterator_traits<std::decay_t<RandomAccessIterator>>::difference_type used{}, cap=target_limit; \
  955. auto output = [&](unsigned char l) \
  956. { \
  957. if(used >= cap) return true; \
  958. target[used] = l; ++used; \
  959. return false; \
  960. }; \
  961. auto outputcopy = [&](std::uint_least16_t length, std::uint_fast32_t offs) \
  962. { \
  963. /* length=0 means that offs is the size of the window. */ \
  964. for(; length > 0 && used < cap; ++used, --length) \
  965. { \
  966. target[used] = target[used - offs]; \
  967. } \
  968. return length; \
  969. };
  970. #define DEFL_MACRO_Outr2 \
  971. auto output = [&](unsigned char l) \
  972. { \
  973. if(target_begin == target_end) return true; \
  974. *target_begin = l; ++target_begin; \
  975. return false; \
  976. }; \
  977. auto outputcopy = [&](std::uint_least16_t length, std::uint_fast32_t offs) \
  978. { \
  979. /* length=0 means that offs is the size of the window. */ \
  980. for(; length > 0 && !(target_begin == target_end); --length, ++target_begin) \
  981. { \
  982. *target_begin = *(target_begin - offs); \
  983. } \
  984. return length; \
  985. };
  986. #define DEFL_MACRO_Tk0 \
  987. return gunzip_ns::Gunzip<Abortable>(inputfun, output, outputcopy, btfun);
  988. #define DEFL_MACRO_Tki \
  989. gunzip_ns::SizeTracker<DeflateTrackInSize> tracker; \
  990. return tracker(gunzip_ns::Gunzip<Abortable>(tracker.template ForwardInput(inputfun), output, outputcopy, btfun));
  991. #define DEFL_MACRO_Tko \
  992. gunzip_ns::SizeTracker<DeflateTrackOutSize> tracker; \
  993. return tracker(gunzip_ns::Gunzip<Abortable>(inputfun, tracker.template ForwardOutput(output), tracker.template ForwardWindow(outputcopy), btfun));
  994. #define DEFL_MACRO_Tkb \
  995. gunzip_ns::SizeTracker<DeflateTrackBothSize> tracker; \
  996. return tracker(gunzip_ns::Gunzip<Abortable>(tracker.template ForwardInput(inputfun), tracker.template ForwardOutput(output), tracker.template ForwardWindow(outputcopy), btfun));
  997. template<typename InputFunctor,typename OutputFunctor,typename WindowFunctor>
  998. std::enable_if_t<DeflIsInputFunctor && DeflIsOutputFunctor && DeflIsWindowFunctor, int>
  999. Deflate(InputFunctor&& inputfun,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackNoSize = {})
  1000. {
  1001. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1002. DEFL_MACRO_Inf DEFL_MACRO_Tk0
  1003. }
  1004. template<typename InputFunctor,typename OutputFunctor,typename WindowFunctor>
  1005. std::enable_if_t<DeflIsInputFunctor && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::uint_fast64_t>>
  1006. Deflate(InputFunctor&& inputfun,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackInSize)
  1007. {
  1008. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1009. DEFL_MACRO_Inf DEFL_MACRO_Tki
  1010. }
  1011. template<typename InputFunctor,typename OutputFunctor,typename WindowFunctor>
  1012. std::enable_if_t<DeflIsInputFunctor && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::uint_fast64_t>>
  1013. Deflate(InputFunctor&& inputfun,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackOutSize)
  1014. {
  1015. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1016. DEFL_MACRO_Inf DEFL_MACRO_Tko
  1017. }
  1018. template<typename InputFunctor,typename OutputFunctor,typename WindowFunctor>
  1019. std::enable_if_t<DeflIsInputFunctor && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1020. Deflate(InputFunctor&& inputfun,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackBothSize)
  1021. {
  1022. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1023. DEFL_MACRO_Inf DEFL_MACRO_Tkb
  1024. }
  1025. template<typename InputFunctor,typename OutputFunctor>
  1026. std::enable_if_t<DeflIsInputFunctor && DeflIsOutputFunctor, int>
  1027. Deflate(InputFunctor&& inputfun,OutputFunctor&& output_orig,DeflateTrackNoSize = {})
  1028. {
  1029. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | DeflOutputAbortable_OutputFunctor;
  1030. DEFL_MACRO_Inf DEFL_MACRO_Outf DEFL_MACRO_Tk0
  1031. }
  1032. template<typename InputFunctor,typename OutputFunctor>
  1033. std::enable_if_t<DeflIsInputFunctor && DeflIsOutputFunctor, std::pair<int, std::uint_fast64_t>>
  1034. Deflate(InputFunctor&& inputfun,OutputFunctor&& output_orig,DeflateTrackInSize)
  1035. {
  1036. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | DeflOutputAbortable_OutputFunctor;
  1037. DEFL_MACRO_Inf DEFL_MACRO_Outf DEFL_MACRO_Tki
  1038. }
  1039. template<typename InputFunctor,typename OutputFunctor>
  1040. std::enable_if_t<DeflIsInputFunctor && DeflIsOutputFunctor, std::pair<int, std::uint_fast64_t>>
  1041. Deflate(InputFunctor&& inputfun,OutputFunctor&& output_orig,DeflateTrackOutSize)
  1042. {
  1043. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | DeflOutputAbortable_OutputFunctor;
  1044. DEFL_MACRO_Inf DEFL_MACRO_Outf DEFL_MACRO_Tko
  1045. }
  1046. template<typename InputFunctor,typename OutputFunctor>
  1047. std::enable_if_t<DeflIsInputFunctor && DeflIsOutputFunctor, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1048. Deflate(InputFunctor&& inputfun,OutputFunctor&& output_orig,DeflateTrackBothSize)
  1049. {
  1050. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | DeflOutputAbortable_OutputFunctor;
  1051. DEFL_MACRO_Inf DEFL_MACRO_Outf DEFL_MACRO_Tkb
  1052. }
  1053. template<typename InputFunctor,typename OutputIterator>
  1054. std::enable_if_t<DeflIsInputFunctor && DeflIsOutputIterator, int>
  1055. Deflate(InputFunctor&& inputfun,OutputIterator&& target,DeflateTrackNoSize = {})
  1056. {
  1057. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | 0;
  1058. DEFL_MACRO_Inf DEFL_MACRO_OutI DEFL_MACRO_Tk0
  1059. }
  1060. template<typename InputFunctor,typename OutputIterator>
  1061. std::enable_if_t<DeflIsInputFunctor && DeflIsOutputIterator, std::pair<int, std::uint_fast64_t>>
  1062. Deflate(InputFunctor&& inputfun,OutputIterator&& target,DeflateTrackInSize)
  1063. {
  1064. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | 0;
  1065. DEFL_MACRO_Inf DEFL_MACRO_OutI DEFL_MACRO_Tki
  1066. }
  1067. template<typename InputFunctor,typename OutputIterator>
  1068. std::enable_if_t<DeflIsInputFunctor && DeflIsOutputIterator, std::pair<int, std::uint_fast64_t>>
  1069. Deflate(InputFunctor&& inputfun,OutputIterator&& target,DeflateTrackOutSize)
  1070. {
  1071. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | 0;
  1072. DEFL_MACRO_Inf DEFL_MACRO_OutI DEFL_MACRO_Tko
  1073. }
  1074. template<typename InputFunctor,typename OutputIterator>
  1075. std::enable_if_t<DeflIsInputFunctor && DeflIsOutputIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1076. Deflate(InputFunctor&& inputfun,OutputIterator&& target,DeflateTrackBothSize)
  1077. {
  1078. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | 0;
  1079. DEFL_MACRO_Inf DEFL_MACRO_OutI DEFL_MACRO_Tkb
  1080. }
  1081. template<typename InputFunctor,typename RandomAccessIterator>
  1082. std::enable_if_t<DeflIsInputFunctor && DeflIsRandomAccessIterator, int>
  1083. Deflate(InputFunctor&& inputfun,RandomAccessIterator&& target,DeflateTrackNoSize = {})
  1084. {
  1085. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | 0;
  1086. DEFL_MACRO_Inf DEFL_MACRO_Outr DEFL_MACRO_Tk0
  1087. }
  1088. template<typename InputFunctor,typename RandomAccessIterator>
  1089. std::enable_if_t<DeflIsInputFunctor && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1090. Deflate(InputFunctor&& inputfun,RandomAccessIterator&& target,DeflateTrackInSize)
  1091. {
  1092. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | 0;
  1093. DEFL_MACRO_Inf DEFL_MACRO_Outr DEFL_MACRO_Tki
  1094. }
  1095. template<typename InputFunctor,typename RandomAccessIterator>
  1096. std::enable_if_t<DeflIsInputFunctor && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1097. Deflate(InputFunctor&& inputfun,RandomAccessIterator&& target,DeflateTrackOutSize)
  1098. {
  1099. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | 0;
  1100. DEFL_MACRO_Inf DEFL_MACRO_Outr DEFL_MACRO_Tko
  1101. }
  1102. template<typename InputFunctor,typename RandomAccessIterator>
  1103. std::enable_if_t<DeflIsInputFunctor && DeflIsRandomAccessIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1104. Deflate(InputFunctor&& inputfun,RandomAccessIterator&& target,DeflateTrackBothSize)
  1105. {
  1106. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | 0;
  1107. DEFL_MACRO_Inf DEFL_MACRO_Outr DEFL_MACRO_Tkb
  1108. }
  1109. template<typename InputFunctor,typename RandomAccessIterator,typename SizeType2>
  1110. std::enable_if_t<DeflIsInputFunctor && DeflIsRandomAccessIterator && DeflIsSizeType2, int>
  1111. Deflate(InputFunctor&& inputfun,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackNoSize = {})
  1112. {
  1113. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | 2;
  1114. DEFL_MACRO_Inf DEFL_MACRO_Outrl DEFL_MACRO_Tk0
  1115. }
  1116. template<typename InputFunctor,typename RandomAccessIterator,typename SizeType2>
  1117. std::enable_if_t<DeflIsInputFunctor && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::uint_fast64_t>>
  1118. Deflate(InputFunctor&& inputfun,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackInSize)
  1119. {
  1120. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | 2;
  1121. DEFL_MACRO_Inf DEFL_MACRO_Outrl DEFL_MACRO_Tki
  1122. }
  1123. template<typename InputFunctor,typename RandomAccessIterator,typename SizeType2>
  1124. std::enable_if_t<DeflIsInputFunctor && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::uint_fast64_t>>
  1125. Deflate(InputFunctor&& inputfun,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackOutSize)
  1126. {
  1127. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | 2;
  1128. DEFL_MACRO_Inf DEFL_MACRO_Outrl DEFL_MACRO_Tko
  1129. }
  1130. template<typename InputFunctor,typename RandomAccessIterator,typename SizeType2>
  1131. std::enable_if_t<DeflIsInputFunctor && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1132. Deflate(InputFunctor&& inputfun,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackBothSize)
  1133. {
  1134. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | 2;
  1135. DEFL_MACRO_Inf DEFL_MACRO_Outrl DEFL_MACRO_Tkb
  1136. }
  1137. template<typename InputFunctor,typename RandomAccessIterator>
  1138. std::enable_if_t<DeflIsInputFunctor && DeflIsRandomAccessIterator, int>
  1139. Deflate(InputFunctor&& inputfun,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackNoSize = {})
  1140. {
  1141. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | 2;
  1142. DEFL_MACRO_Inf DEFL_MACRO_Outr2 DEFL_MACRO_Tk0
  1143. }
  1144. template<typename InputFunctor,typename RandomAccessIterator>
  1145. std::enable_if_t<DeflIsInputFunctor && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1146. Deflate(InputFunctor&& inputfun,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackInSize)
  1147. {
  1148. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | 2;
  1149. DEFL_MACRO_Inf DEFL_MACRO_Outr2 DEFL_MACRO_Tki
  1150. }
  1151. template<typename InputFunctor,typename RandomAccessIterator>
  1152. std::enable_if_t<DeflIsInputFunctor && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1153. Deflate(InputFunctor&& inputfun,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackOutSize)
  1154. {
  1155. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | 2;
  1156. DEFL_MACRO_Inf DEFL_MACRO_Outr2 DEFL_MACRO_Tko
  1157. }
  1158. template<typename InputFunctor,typename RandomAccessIterator>
  1159. std::enable_if_t<DeflIsInputFunctor && DeflIsRandomAccessIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1160. Deflate(InputFunctor&& inputfun,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackBothSize)
  1161. {
  1162. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<std::result_of_t<InputFunctor()>>) | 2;
  1163. DEFL_MACRO_Inf DEFL_MACRO_Outr2 DEFL_MACRO_Tkb
  1164. }
  1165. template<typename InputIterator,typename OutputFunctor,typename WindowFunctor>
  1166. std::enable_if_t<DeflIsInputIterator && DeflIsOutputFunctor && DeflIsWindowFunctor, int>
  1167. Deflate(InputIterator&& input,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackNoSize = {})
  1168. {
  1169. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1170. DEFL_MACRO_InI DEFL_MACRO_Tk0
  1171. }
  1172. template<typename InputIterator,typename OutputFunctor,typename WindowFunctor>
  1173. std::enable_if_t<DeflIsInputIterator && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::uint_fast64_t>>
  1174. Deflate(InputIterator&& input,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackInSize)
  1175. {
  1176. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1177. DEFL_MACRO_InI DEFL_MACRO_Tki
  1178. }
  1179. template<typename InputIterator,typename OutputFunctor,typename WindowFunctor>
  1180. std::enable_if_t<DeflIsInputIterator && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::uint_fast64_t>>
  1181. Deflate(InputIterator&& input,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackOutSize)
  1182. {
  1183. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1184. DEFL_MACRO_InI DEFL_MACRO_Tko
  1185. }
  1186. template<typename InputIterator,typename OutputFunctor,typename WindowFunctor>
  1187. std::enable_if_t<DeflIsInputIterator && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1188. Deflate(InputIterator&& input,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackBothSize)
  1189. {
  1190. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1191. DEFL_MACRO_InI DEFL_MACRO_Tkb
  1192. }
  1193. template<typename InputIterator,typename OutputFunctor>
  1194. std::enable_if_t<DeflIsInputIterator && DeflIsOutputFunctor, int>
  1195. Deflate(InputIterator&& input,OutputFunctor&& output_orig,DeflateTrackNoSize = {})
  1196. {
  1197. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | DeflOutputAbortable_OutputFunctor;
  1198. DEFL_MACRO_InI DEFL_MACRO_Outf DEFL_MACRO_Tk0
  1199. }
  1200. template<typename InputIterator,typename OutputFunctor>
  1201. std::enable_if_t<DeflIsInputIterator && DeflIsOutputFunctor, std::pair<int, std::uint_fast64_t>>
  1202. Deflate(InputIterator&& input,OutputFunctor&& output_orig,DeflateTrackInSize)
  1203. {
  1204. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | DeflOutputAbortable_OutputFunctor;
  1205. DEFL_MACRO_InI DEFL_MACRO_Outf DEFL_MACRO_Tki
  1206. }
  1207. template<typename InputIterator,typename OutputFunctor>
  1208. std::enable_if_t<DeflIsInputIterator && DeflIsOutputFunctor, std::pair<int, std::uint_fast64_t>>
  1209. Deflate(InputIterator&& input,OutputFunctor&& output_orig,DeflateTrackOutSize)
  1210. {
  1211. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | DeflOutputAbortable_OutputFunctor;
  1212. DEFL_MACRO_InI DEFL_MACRO_Outf DEFL_MACRO_Tko
  1213. }
  1214. template<typename InputIterator,typename OutputFunctor>
  1215. std::enable_if_t<DeflIsInputIterator && DeflIsOutputFunctor, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1216. Deflate(InputIterator&& input,OutputFunctor&& output_orig,DeflateTrackBothSize)
  1217. {
  1218. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | DeflOutputAbortable_OutputFunctor;
  1219. DEFL_MACRO_InI DEFL_MACRO_Outf DEFL_MACRO_Tkb
  1220. }
  1221. template<typename InputIterator,typename OutputIterator>
  1222. std::enable_if_t<DeflIsInputIterator && DeflIsOutputIterator, int>
  1223. Deflate(InputIterator&& input,OutputIterator&& target,DeflateTrackNoSize = {})
  1224. {
  1225. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | 0;
  1226. DEFL_MACRO_InI DEFL_MACRO_OutI DEFL_MACRO_Tk0
  1227. }
  1228. template<typename InputIterator,typename OutputIterator>
  1229. std::enable_if_t<DeflIsInputIterator && DeflIsOutputIterator, std::pair<int, std::uint_fast64_t>>
  1230. Deflate(InputIterator&& input,OutputIterator&& target,DeflateTrackInSize)
  1231. {
  1232. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | 0;
  1233. DEFL_MACRO_InI DEFL_MACRO_OutI DEFL_MACRO_Tki
  1234. }
  1235. template<typename InputIterator,typename OutputIterator>
  1236. std::enable_if_t<DeflIsInputIterator && DeflIsOutputIterator, std::pair<int, std::uint_fast64_t>>
  1237. Deflate(InputIterator&& input,OutputIterator&& target,DeflateTrackOutSize)
  1238. {
  1239. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | 0;
  1240. DEFL_MACRO_InI DEFL_MACRO_OutI DEFL_MACRO_Tko
  1241. }
  1242. template<typename InputIterator,typename OutputIterator>
  1243. std::enable_if_t<DeflIsInputIterator && DeflIsOutputIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1244. Deflate(InputIterator&& input,OutputIterator&& target,DeflateTrackBothSize)
  1245. {
  1246. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | 0;
  1247. DEFL_MACRO_InI DEFL_MACRO_OutI DEFL_MACRO_Tkb
  1248. }
  1249. template<typename InputIterator,typename RandomAccessIterator>
  1250. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator, int>
  1251. Deflate(InputIterator&& input,RandomAccessIterator&& target,DeflateTrackNoSize = {})
  1252. {
  1253. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | 0;
  1254. DEFL_MACRO_InI DEFL_MACRO_Outr DEFL_MACRO_Tk0
  1255. }
  1256. template<typename InputIterator,typename RandomAccessIterator>
  1257. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1258. Deflate(InputIterator&& input,RandomAccessIterator&& target,DeflateTrackInSize)
  1259. {
  1260. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | 0;
  1261. DEFL_MACRO_InI DEFL_MACRO_Outr DEFL_MACRO_Tki
  1262. }
  1263. template<typename InputIterator,typename RandomAccessIterator>
  1264. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1265. Deflate(InputIterator&& input,RandomAccessIterator&& target,DeflateTrackOutSize)
  1266. {
  1267. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | 0;
  1268. DEFL_MACRO_InI DEFL_MACRO_Outr DEFL_MACRO_Tko
  1269. }
  1270. template<typename InputIterator,typename RandomAccessIterator>
  1271. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1272. Deflate(InputIterator&& input,RandomAccessIterator&& target,DeflateTrackBothSize)
  1273. {
  1274. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | 0;
  1275. DEFL_MACRO_InI DEFL_MACRO_Outr DEFL_MACRO_Tkb
  1276. }
  1277. template<typename InputIterator,typename RandomAccessIterator,typename SizeType2>
  1278. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator && DeflIsSizeType2, int>
  1279. Deflate(InputIterator&& input,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackNoSize = {})
  1280. {
  1281. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | 2;
  1282. DEFL_MACRO_InI DEFL_MACRO_Outrl DEFL_MACRO_Tk0
  1283. }
  1284. template<typename InputIterator,typename RandomAccessIterator,typename SizeType2>
  1285. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::uint_fast64_t>>
  1286. Deflate(InputIterator&& input,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackInSize)
  1287. {
  1288. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | 2;
  1289. DEFL_MACRO_InI DEFL_MACRO_Outrl DEFL_MACRO_Tki
  1290. }
  1291. template<typename InputIterator,typename RandomAccessIterator,typename SizeType2>
  1292. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::uint_fast64_t>>
  1293. Deflate(InputIterator&& input,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackOutSize)
  1294. {
  1295. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | 2;
  1296. DEFL_MACRO_InI DEFL_MACRO_Outrl DEFL_MACRO_Tko
  1297. }
  1298. template<typename InputIterator,typename RandomAccessIterator,typename SizeType2>
  1299. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1300. Deflate(InputIterator&& input,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackBothSize)
  1301. {
  1302. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | 2;
  1303. DEFL_MACRO_InI DEFL_MACRO_Outrl DEFL_MACRO_Tkb
  1304. }
  1305. template<typename InputIterator,typename RandomAccessIterator>
  1306. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator, int>
  1307. Deflate(InputIterator&& input,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackNoSize = {})
  1308. {
  1309. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | 2;
  1310. DEFL_MACRO_InI DEFL_MACRO_Outr2 DEFL_MACRO_Tk0
  1311. }
  1312. template<typename InputIterator,typename RandomAccessIterator>
  1313. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1314. Deflate(InputIterator&& input,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackInSize)
  1315. {
  1316. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | 2;
  1317. DEFL_MACRO_InI DEFL_MACRO_Outr2 DEFL_MACRO_Tki
  1318. }
  1319. template<typename InputIterator,typename RandomAccessIterator>
  1320. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1321. Deflate(InputIterator&& input,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackOutSize)
  1322. {
  1323. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | 2;
  1324. DEFL_MACRO_InI DEFL_MACRO_Outr2 DEFL_MACRO_Tko
  1325. }
  1326. template<typename InputIterator,typename RandomAccessIterator>
  1327. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1328. Deflate(InputIterator&& input,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackBothSize)
  1329. {
  1330. constexpr unsigned char Abortable = DeflInputAbortable_Type(std::decay_t<decltype(*input)>) | 2;
  1331. DEFL_MACRO_InI DEFL_MACRO_Outr2 DEFL_MACRO_Tkb
  1332. }
  1333. template<typename InputIterator,typename OutputFunctor,typename WindowFunctor>
  1334. std::enable_if_t<DeflIsInputIterator && DeflIsOutputFunctor && DeflIsWindowFunctor, int>
  1335. Deflate(InputIterator&& begin,InputIterator&& end,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackNoSize = {})
  1336. {
  1337. constexpr unsigned char Abortable = 1 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1338. DEFL_MACRO_InI2 DEFL_MACRO_Tk0
  1339. }
  1340. template<typename InputIterator,typename OutputFunctor,typename WindowFunctor>
  1341. std::enable_if_t<DeflIsInputIterator && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::uint_fast64_t>>
  1342. Deflate(InputIterator&& begin,InputIterator&& end,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackInSize)
  1343. {
  1344. constexpr unsigned char Abortable = 1 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1345. DEFL_MACRO_InI2 DEFL_MACRO_Tki
  1346. }
  1347. template<typename InputIterator,typename OutputFunctor,typename WindowFunctor>
  1348. std::enable_if_t<DeflIsInputIterator && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::uint_fast64_t>>
  1349. Deflate(InputIterator&& begin,InputIterator&& end,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackOutSize)
  1350. {
  1351. constexpr unsigned char Abortable = 1 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1352. DEFL_MACRO_InI2 DEFL_MACRO_Tko
  1353. }
  1354. template<typename InputIterator,typename OutputFunctor,typename WindowFunctor>
  1355. std::enable_if_t<DeflIsInputIterator && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1356. Deflate(InputIterator&& begin,InputIterator&& end,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackBothSize)
  1357. {
  1358. constexpr unsigned char Abortable = 1 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1359. DEFL_MACRO_InI2 DEFL_MACRO_Tkb
  1360. }
  1361. template<typename InputIterator,typename OutputFunctor>
  1362. std::enable_if_t<DeflIsInputIterator && DeflIsOutputFunctor, int>
  1363. Deflate(InputIterator&& begin,InputIterator&& end,OutputFunctor&& output_orig,DeflateTrackNoSize = {})
  1364. {
  1365. constexpr unsigned char Abortable = 1 | DeflOutputAbortable_OutputFunctor;
  1366. DEFL_MACRO_InI2 DEFL_MACRO_Outf DEFL_MACRO_Tk0
  1367. }
  1368. template<typename InputIterator,typename OutputFunctor>
  1369. std::enable_if_t<DeflIsInputIterator && DeflIsOutputFunctor, std::pair<int, std::uint_fast64_t>>
  1370. Deflate(InputIterator&& begin,InputIterator&& end,OutputFunctor&& output_orig,DeflateTrackInSize)
  1371. {
  1372. constexpr unsigned char Abortable = 1 | DeflOutputAbortable_OutputFunctor;
  1373. DEFL_MACRO_InI2 DEFL_MACRO_Outf DEFL_MACRO_Tki
  1374. }
  1375. template<typename InputIterator,typename OutputFunctor>
  1376. std::enable_if_t<DeflIsInputIterator && DeflIsOutputFunctor, std::pair<int, std::uint_fast64_t>>
  1377. Deflate(InputIterator&& begin,InputIterator&& end,OutputFunctor&& output_orig,DeflateTrackOutSize)
  1378. {
  1379. constexpr unsigned char Abortable = 1 | DeflOutputAbortable_OutputFunctor;
  1380. DEFL_MACRO_InI2 DEFL_MACRO_Outf DEFL_MACRO_Tko
  1381. }
  1382. template<typename InputIterator,typename OutputFunctor>
  1383. std::enable_if_t<DeflIsInputIterator && DeflIsOutputFunctor, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1384. Deflate(InputIterator&& begin,InputIterator&& end,OutputFunctor&& output_orig,DeflateTrackBothSize)
  1385. {
  1386. constexpr unsigned char Abortable = 1 | DeflOutputAbortable_OutputFunctor;
  1387. DEFL_MACRO_InI2 DEFL_MACRO_Outf DEFL_MACRO_Tkb
  1388. }
  1389. template<typename InputIterator,typename OutputIterator>
  1390. std::enable_if_t<DeflIsInputIterator && DeflIsOutputIterator, int>
  1391. Deflate(InputIterator&& begin,InputIterator&& end,OutputIterator&& target,DeflateTrackNoSize = {})
  1392. {
  1393. constexpr unsigned char Abortable = 1 | 0;
  1394. DEFL_MACRO_InI2 DEFL_MACRO_OutI DEFL_MACRO_Tk0
  1395. }
  1396. template<typename InputIterator,typename OutputIterator>
  1397. std::enable_if_t<DeflIsInputIterator && DeflIsOutputIterator, std::pair<int, std::uint_fast64_t>>
  1398. Deflate(InputIterator&& begin,InputIterator&& end,OutputIterator&& target,DeflateTrackInSize)
  1399. {
  1400. constexpr unsigned char Abortable = 1 | 0;
  1401. DEFL_MACRO_InI2 DEFL_MACRO_OutI DEFL_MACRO_Tki
  1402. }
  1403. template<typename InputIterator,typename OutputIterator>
  1404. std::enable_if_t<DeflIsInputIterator && DeflIsOutputIterator, std::pair<int, std::uint_fast64_t>>
  1405. Deflate(InputIterator&& begin,InputIterator&& end,OutputIterator&& target,DeflateTrackOutSize)
  1406. {
  1407. constexpr unsigned char Abortable = 1 | 0;
  1408. DEFL_MACRO_InI2 DEFL_MACRO_OutI DEFL_MACRO_Tko
  1409. }
  1410. template<typename InputIterator,typename OutputIterator>
  1411. std::enable_if_t<DeflIsInputIterator && DeflIsOutputIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1412. Deflate(InputIterator&& begin,InputIterator&& end,OutputIterator&& target,DeflateTrackBothSize)
  1413. {
  1414. constexpr unsigned char Abortable = 1 | 0;
  1415. DEFL_MACRO_InI2 DEFL_MACRO_OutI DEFL_MACRO_Tkb
  1416. }
  1417. template<typename InputIterator,typename RandomAccessIterator>
  1418. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator, int>
  1419. Deflate(InputIterator&& begin,InputIterator&& end,RandomAccessIterator&& target,DeflateTrackNoSize = {})
  1420. {
  1421. constexpr unsigned char Abortable = 1 | 0;
  1422. DEFL_MACRO_InI2 DEFL_MACRO_Outr DEFL_MACRO_Tk0
  1423. }
  1424. template<typename InputIterator,typename RandomAccessIterator>
  1425. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1426. Deflate(InputIterator&& begin,InputIterator&& end,RandomAccessIterator&& target,DeflateTrackInSize)
  1427. {
  1428. constexpr unsigned char Abortable = 1 | 0;
  1429. DEFL_MACRO_InI2 DEFL_MACRO_Outr DEFL_MACRO_Tki
  1430. }
  1431. template<typename InputIterator,typename RandomAccessIterator>
  1432. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1433. Deflate(InputIterator&& begin,InputIterator&& end,RandomAccessIterator&& target,DeflateTrackOutSize)
  1434. {
  1435. constexpr unsigned char Abortable = 1 | 0;
  1436. DEFL_MACRO_InI2 DEFL_MACRO_Outr DEFL_MACRO_Tko
  1437. }
  1438. template<typename InputIterator,typename RandomAccessIterator>
  1439. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1440. Deflate(InputIterator&& begin,InputIterator&& end,RandomAccessIterator&& target,DeflateTrackBothSize)
  1441. {
  1442. constexpr unsigned char Abortable = 1 | 0;
  1443. DEFL_MACRO_InI2 DEFL_MACRO_Outr DEFL_MACRO_Tkb
  1444. }
  1445. template<typename InputIterator,typename RandomAccessIterator,typename SizeType2>
  1446. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator && DeflIsSizeType2, int>
  1447. Deflate(InputIterator&& begin,InputIterator&& end,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackNoSize = {})
  1448. {
  1449. constexpr unsigned char Abortable = 1 | 2;
  1450. DEFL_MACRO_InI2 DEFL_MACRO_Outrl DEFL_MACRO_Tk0
  1451. }
  1452. template<typename InputIterator,typename RandomAccessIterator,typename SizeType2>
  1453. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::uint_fast64_t>>
  1454. Deflate(InputIterator&& begin,InputIterator&& end,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackInSize)
  1455. {
  1456. constexpr unsigned char Abortable = 1 | 2;
  1457. DEFL_MACRO_InI2 DEFL_MACRO_Outrl DEFL_MACRO_Tki
  1458. }
  1459. template<typename InputIterator,typename RandomAccessIterator,typename SizeType2>
  1460. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::uint_fast64_t>>
  1461. Deflate(InputIterator&& begin,InputIterator&& end,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackOutSize)
  1462. {
  1463. constexpr unsigned char Abortable = 1 | 2;
  1464. DEFL_MACRO_InI2 DEFL_MACRO_Outrl DEFL_MACRO_Tko
  1465. }
  1466. template<typename InputIterator,typename RandomAccessIterator,typename SizeType2>
  1467. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1468. Deflate(InputIterator&& begin,InputIterator&& end,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackBothSize)
  1469. {
  1470. constexpr unsigned char Abortable = 1 | 2;
  1471. DEFL_MACRO_InI2 DEFL_MACRO_Outrl DEFL_MACRO_Tkb
  1472. }
  1473. template<typename InputIterator,typename RandomAccessIterator>
  1474. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator, int>
  1475. Deflate(InputIterator&& begin,InputIterator&& end,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackNoSize = {})
  1476. {
  1477. constexpr unsigned char Abortable = 1 | 2;
  1478. DEFL_MACRO_InI2 DEFL_MACRO_Outr2 DEFL_MACRO_Tk0
  1479. }
  1480. template<typename InputIterator,typename RandomAccessIterator>
  1481. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1482. Deflate(InputIterator&& begin,InputIterator&& end,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackInSize)
  1483. {
  1484. constexpr unsigned char Abortable = 1 | 2;
  1485. DEFL_MACRO_InI2 DEFL_MACRO_Outr2 DEFL_MACRO_Tki
  1486. }
  1487. template<typename InputIterator,typename RandomAccessIterator>
  1488. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1489. Deflate(InputIterator&& begin,InputIterator&& end,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackOutSize)
  1490. {
  1491. constexpr unsigned char Abortable = 1 | 2;
  1492. DEFL_MACRO_InI2 DEFL_MACRO_Outr2 DEFL_MACRO_Tko
  1493. }
  1494. template<typename InputIterator,typename RandomAccessIterator>
  1495. std::enable_if_t<DeflIsInputIterator && DeflIsRandomAccessIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1496. Deflate(InputIterator&& begin,InputIterator&& end,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackBothSize)
  1497. {
  1498. constexpr unsigned char Abortable = 1 | 2;
  1499. DEFL_MACRO_InI2 DEFL_MACRO_Outr2 DEFL_MACRO_Tkb
  1500. }
  1501. template<typename InputIterator,typename SizeType,typename OutputFunctor,typename WindowFunctor>
  1502. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsOutputFunctor && DeflIsWindowFunctor, int>
  1503. Deflate(InputIterator&& begin,SizeType&& length,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackNoSize = {})
  1504. {
  1505. constexpr unsigned char Abortable = 1 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1506. DEFL_MACRO_InIl DEFL_MACRO_Tk0
  1507. }
  1508. template<typename InputIterator,typename SizeType,typename OutputFunctor,typename WindowFunctor>
  1509. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::uint_fast64_t>>
  1510. Deflate(InputIterator&& begin,SizeType&& length,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackInSize)
  1511. {
  1512. constexpr unsigned char Abortable = 1 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1513. DEFL_MACRO_InIl DEFL_MACRO_Tki
  1514. }
  1515. template<typename InputIterator,typename SizeType,typename OutputFunctor,typename WindowFunctor>
  1516. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::uint_fast64_t>>
  1517. Deflate(InputIterator&& begin,SizeType&& length,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackOutSize)
  1518. {
  1519. constexpr unsigned char Abortable = 1 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1520. DEFL_MACRO_InIl DEFL_MACRO_Tko
  1521. }
  1522. template<typename InputIterator,typename SizeType,typename OutputFunctor,typename WindowFunctor>
  1523. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1524. Deflate(InputIterator&& begin,SizeType&& length,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackBothSize)
  1525. {
  1526. constexpr unsigned char Abortable = 1 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1527. DEFL_MACRO_InIl DEFL_MACRO_Tkb
  1528. }
  1529. template<typename InputIterator,typename SizeType,typename OutputFunctor>
  1530. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsOutputFunctor, int>
  1531. Deflate(InputIterator&& begin,SizeType&& length,OutputFunctor&& output_orig,DeflateTrackNoSize = {})
  1532. {
  1533. constexpr unsigned char Abortable = 1 | DeflOutputAbortable_OutputFunctor;
  1534. DEFL_MACRO_InIl DEFL_MACRO_Outf DEFL_MACRO_Tk0
  1535. }
  1536. template<typename InputIterator,typename SizeType,typename OutputFunctor>
  1537. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsOutputFunctor, std::pair<int, std::uint_fast64_t>>
  1538. Deflate(InputIterator&& begin,SizeType&& length,OutputFunctor&& output_orig,DeflateTrackInSize)
  1539. {
  1540. constexpr unsigned char Abortable = 1 | DeflOutputAbortable_OutputFunctor;
  1541. DEFL_MACRO_InIl DEFL_MACRO_Outf DEFL_MACRO_Tki
  1542. }
  1543. template<typename InputIterator,typename SizeType,typename OutputFunctor>
  1544. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsOutputFunctor, std::pair<int, std::uint_fast64_t>>
  1545. Deflate(InputIterator&& begin,SizeType&& length,OutputFunctor&& output_orig,DeflateTrackOutSize)
  1546. {
  1547. constexpr unsigned char Abortable = 1 | DeflOutputAbortable_OutputFunctor;
  1548. DEFL_MACRO_InIl DEFL_MACRO_Outf DEFL_MACRO_Tko
  1549. }
  1550. template<typename InputIterator,typename SizeType,typename OutputFunctor>
  1551. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsOutputFunctor, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1552. Deflate(InputIterator&& begin,SizeType&& length,OutputFunctor&& output_orig,DeflateTrackBothSize)
  1553. {
  1554. constexpr unsigned char Abortable = 1 | DeflOutputAbortable_OutputFunctor;
  1555. DEFL_MACRO_InIl DEFL_MACRO_Outf DEFL_MACRO_Tkb
  1556. }
  1557. template<typename InputIterator,typename SizeType,typename OutputIterator>
  1558. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsOutputIterator, int>
  1559. Deflate(InputIterator&& begin,SizeType&& length,OutputIterator&& target,DeflateTrackNoSize = {})
  1560. {
  1561. constexpr unsigned char Abortable = 1 | 0;
  1562. DEFL_MACRO_InIl DEFL_MACRO_OutI DEFL_MACRO_Tk0
  1563. }
  1564. template<typename InputIterator,typename SizeType,typename OutputIterator>
  1565. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsOutputIterator, std::pair<int, std::uint_fast64_t>>
  1566. Deflate(InputIterator&& begin,SizeType&& length,OutputIterator&& target,DeflateTrackInSize)
  1567. {
  1568. constexpr unsigned char Abortable = 1 | 0;
  1569. DEFL_MACRO_InIl DEFL_MACRO_OutI DEFL_MACRO_Tki
  1570. }
  1571. template<typename InputIterator,typename SizeType,typename OutputIterator>
  1572. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsOutputIterator, std::pair<int, std::uint_fast64_t>>
  1573. Deflate(InputIterator&& begin,SizeType&& length,OutputIterator&& target,DeflateTrackOutSize)
  1574. {
  1575. constexpr unsigned char Abortable = 1 | 0;
  1576. DEFL_MACRO_InIl DEFL_MACRO_OutI DEFL_MACRO_Tko
  1577. }
  1578. template<typename InputIterator,typename SizeType,typename OutputIterator>
  1579. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsOutputIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1580. Deflate(InputIterator&& begin,SizeType&& length,OutputIterator&& target,DeflateTrackBothSize)
  1581. {
  1582. constexpr unsigned char Abortable = 1 | 0;
  1583. DEFL_MACRO_InIl DEFL_MACRO_OutI DEFL_MACRO_Tkb
  1584. }
  1585. template<typename InputIterator,typename SizeType,typename RandomAccessIterator>
  1586. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsRandomAccessIterator, int>
  1587. Deflate(InputIterator&& begin,SizeType&& length,RandomAccessIterator&& target,DeflateTrackNoSize = {})
  1588. {
  1589. constexpr unsigned char Abortable = 1 | 0;
  1590. DEFL_MACRO_InIl DEFL_MACRO_Outr DEFL_MACRO_Tk0
  1591. }
  1592. template<typename InputIterator,typename SizeType,typename RandomAccessIterator>
  1593. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1594. Deflate(InputIterator&& begin,SizeType&& length,RandomAccessIterator&& target,DeflateTrackInSize)
  1595. {
  1596. constexpr unsigned char Abortable = 1 | 0;
  1597. DEFL_MACRO_InIl DEFL_MACRO_Outr DEFL_MACRO_Tki
  1598. }
  1599. template<typename InputIterator,typename SizeType,typename RandomAccessIterator>
  1600. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1601. Deflate(InputIterator&& begin,SizeType&& length,RandomAccessIterator&& target,DeflateTrackOutSize)
  1602. {
  1603. constexpr unsigned char Abortable = 1 | 0;
  1604. DEFL_MACRO_InIl DEFL_MACRO_Outr DEFL_MACRO_Tko
  1605. }
  1606. template<typename InputIterator,typename SizeType,typename RandomAccessIterator>
  1607. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsRandomAccessIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1608. Deflate(InputIterator&& begin,SizeType&& length,RandomAccessIterator&& target,DeflateTrackBothSize)
  1609. {
  1610. constexpr unsigned char Abortable = 1 | 0;
  1611. DEFL_MACRO_InIl DEFL_MACRO_Outr DEFL_MACRO_Tkb
  1612. }
  1613. template<typename InputIterator,typename SizeType,typename RandomAccessIterator,typename SizeType2>
  1614. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsRandomAccessIterator && DeflIsSizeType2, int>
  1615. Deflate(InputIterator&& begin,SizeType&& length,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackNoSize = {})
  1616. {
  1617. constexpr unsigned char Abortable = 1 | 2;
  1618. DEFL_MACRO_InIl DEFL_MACRO_Outrl DEFL_MACRO_Tk0
  1619. }
  1620. template<typename InputIterator,typename SizeType,typename RandomAccessIterator,typename SizeType2>
  1621. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::uint_fast64_t>>
  1622. Deflate(InputIterator&& begin,SizeType&& length,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackInSize)
  1623. {
  1624. constexpr unsigned char Abortable = 1 | 2;
  1625. DEFL_MACRO_InIl DEFL_MACRO_Outrl DEFL_MACRO_Tki
  1626. }
  1627. template<typename InputIterator,typename SizeType,typename RandomAccessIterator,typename SizeType2>
  1628. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::uint_fast64_t>>
  1629. Deflate(InputIterator&& begin,SizeType&& length,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackOutSize)
  1630. {
  1631. constexpr unsigned char Abortable = 1 | 2;
  1632. DEFL_MACRO_InIl DEFL_MACRO_Outrl DEFL_MACRO_Tko
  1633. }
  1634. template<typename InputIterator,typename SizeType,typename RandomAccessIterator,typename SizeType2>
  1635. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1636. Deflate(InputIterator&& begin,SizeType&& length,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackBothSize)
  1637. {
  1638. constexpr unsigned char Abortable = 1 | 2;
  1639. DEFL_MACRO_InIl DEFL_MACRO_Outrl DEFL_MACRO_Tkb
  1640. }
  1641. template<typename InputIterator,typename SizeType,typename RandomAccessIterator>
  1642. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsRandomAccessIterator, int>
  1643. Deflate(InputIterator&& begin,SizeType&& length,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackNoSize = {})
  1644. {
  1645. constexpr unsigned char Abortable = 1 | 2;
  1646. DEFL_MACRO_InIl DEFL_MACRO_Outr2 DEFL_MACRO_Tk0
  1647. }
  1648. template<typename InputIterator,typename SizeType,typename RandomAccessIterator>
  1649. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1650. Deflate(InputIterator&& begin,SizeType&& length,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackInSize)
  1651. {
  1652. constexpr unsigned char Abortable = 1 | 2;
  1653. DEFL_MACRO_InIl DEFL_MACRO_Outr2 DEFL_MACRO_Tki
  1654. }
  1655. template<typename InputIterator,typename SizeType,typename RandomAccessIterator>
  1656. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1657. Deflate(InputIterator&& begin,SizeType&& length,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackOutSize)
  1658. {
  1659. constexpr unsigned char Abortable = 1 | 2;
  1660. DEFL_MACRO_InIl DEFL_MACRO_Outr2 DEFL_MACRO_Tko
  1661. }
  1662. template<typename InputIterator,typename SizeType,typename RandomAccessIterator>
  1663. std::enable_if_t<DeflIsInputIterator && DeflIsSizeType && DeflIsRandomAccessIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1664. Deflate(InputIterator&& begin,SizeType&& length,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackBothSize)
  1665. {
  1666. constexpr unsigned char Abortable = 1 | 2;
  1667. DEFL_MACRO_InIl DEFL_MACRO_Outr2 DEFL_MACRO_Tkb
  1668. }
  1669. template<typename BidirIterator,typename SizeType,typename OutputFunctor,typename WindowFunctor>
  1670. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsOutputFunctor && DeflIsWindowFunctor, int>
  1671. Deflate(BidirIterator&& begin,SizeType&& length,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackNoSize = {})
  1672. {
  1673. constexpr unsigned char Abortable = 1 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1674. DEFL_MACRO_InBl DEFL_MACRO_Tk0
  1675. }
  1676. template<typename BidirIterator,typename SizeType,typename OutputFunctor,typename WindowFunctor>
  1677. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::uint_fast64_t>>
  1678. Deflate(BidirIterator&& begin,SizeType&& length,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackInSize)
  1679. {
  1680. constexpr unsigned char Abortable = 1 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1681. DEFL_MACRO_InBl DEFL_MACRO_Tki
  1682. }
  1683. template<typename BidirIterator,typename SizeType,typename OutputFunctor,typename WindowFunctor>
  1684. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::uint_fast64_t>>
  1685. Deflate(BidirIterator&& begin,SizeType&& length,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackOutSize)
  1686. {
  1687. constexpr unsigned char Abortable = 1 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1688. DEFL_MACRO_InBl DEFL_MACRO_Tko
  1689. }
  1690. template<typename BidirIterator,typename SizeType,typename OutputFunctor,typename WindowFunctor>
  1691. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1692. Deflate(BidirIterator&& begin,SizeType&& length,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackBothSize)
  1693. {
  1694. constexpr unsigned char Abortable = 1 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1695. DEFL_MACRO_InBl DEFL_MACRO_Tkb
  1696. }
  1697. template<typename BidirIterator,typename SizeType,typename OutputFunctor>
  1698. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsOutputFunctor, int>
  1699. Deflate(BidirIterator&& begin,SizeType&& length,OutputFunctor&& output_orig,DeflateTrackNoSize = {})
  1700. {
  1701. constexpr unsigned char Abortable = 1 | DeflOutputAbortable_OutputFunctor;
  1702. DEFL_MACRO_InBl DEFL_MACRO_Outf DEFL_MACRO_Tk0
  1703. }
  1704. template<typename BidirIterator,typename SizeType,typename OutputFunctor>
  1705. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsOutputFunctor, std::pair<int, std::uint_fast64_t>>
  1706. Deflate(BidirIterator&& begin,SizeType&& length,OutputFunctor&& output_orig,DeflateTrackInSize)
  1707. {
  1708. constexpr unsigned char Abortable = 1 | DeflOutputAbortable_OutputFunctor;
  1709. DEFL_MACRO_InBl DEFL_MACRO_Outf DEFL_MACRO_Tki
  1710. }
  1711. template<typename BidirIterator,typename SizeType,typename OutputFunctor>
  1712. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsOutputFunctor, std::pair<int, std::uint_fast64_t>>
  1713. Deflate(BidirIterator&& begin,SizeType&& length,OutputFunctor&& output_orig,DeflateTrackOutSize)
  1714. {
  1715. constexpr unsigned char Abortable = 1 | DeflOutputAbortable_OutputFunctor;
  1716. DEFL_MACRO_InBl DEFL_MACRO_Outf DEFL_MACRO_Tko
  1717. }
  1718. template<typename BidirIterator,typename SizeType,typename OutputFunctor>
  1719. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsOutputFunctor, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1720. Deflate(BidirIterator&& begin,SizeType&& length,OutputFunctor&& output_orig,DeflateTrackBothSize)
  1721. {
  1722. constexpr unsigned char Abortable = 1 | DeflOutputAbortable_OutputFunctor;
  1723. DEFL_MACRO_InBl DEFL_MACRO_Outf DEFL_MACRO_Tkb
  1724. }
  1725. template<typename BidirIterator,typename SizeType,typename OutputIterator>
  1726. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsOutputIterator, int>
  1727. Deflate(BidirIterator&& begin,SizeType&& length,OutputIterator&& target,DeflateTrackNoSize = {})
  1728. {
  1729. constexpr unsigned char Abortable = 1 | 0;
  1730. DEFL_MACRO_InBl DEFL_MACRO_OutI DEFL_MACRO_Tk0
  1731. }
  1732. template<typename BidirIterator,typename SizeType,typename OutputIterator>
  1733. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsOutputIterator, std::pair<int, std::uint_fast64_t>>
  1734. Deflate(BidirIterator&& begin,SizeType&& length,OutputIterator&& target,DeflateTrackInSize)
  1735. {
  1736. constexpr unsigned char Abortable = 1 | 0;
  1737. DEFL_MACRO_InBl DEFL_MACRO_OutI DEFL_MACRO_Tki
  1738. }
  1739. template<typename BidirIterator,typename SizeType,typename OutputIterator>
  1740. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsOutputIterator, std::pair<int, std::uint_fast64_t>>
  1741. Deflate(BidirIterator&& begin,SizeType&& length,OutputIterator&& target,DeflateTrackOutSize)
  1742. {
  1743. constexpr unsigned char Abortable = 1 | 0;
  1744. DEFL_MACRO_InBl DEFL_MACRO_OutI DEFL_MACRO_Tko
  1745. }
  1746. template<typename BidirIterator,typename SizeType,typename OutputIterator>
  1747. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsOutputIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1748. Deflate(BidirIterator&& begin,SizeType&& length,OutputIterator&& target,DeflateTrackBothSize)
  1749. {
  1750. constexpr unsigned char Abortable = 1 | 0;
  1751. DEFL_MACRO_InBl DEFL_MACRO_OutI DEFL_MACRO_Tkb
  1752. }
  1753. template<typename BidirIterator,typename SizeType,typename RandomAccessIterator>
  1754. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsRandomAccessIterator, int>
  1755. Deflate(BidirIterator&& begin,SizeType&& length,RandomAccessIterator&& target,DeflateTrackNoSize = {})
  1756. {
  1757. constexpr unsigned char Abortable = 1 | 0;
  1758. DEFL_MACRO_InBl DEFL_MACRO_Outr DEFL_MACRO_Tk0
  1759. }
  1760. template<typename BidirIterator,typename SizeType,typename RandomAccessIterator>
  1761. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1762. Deflate(BidirIterator&& begin,SizeType&& length,RandomAccessIterator&& target,DeflateTrackInSize)
  1763. {
  1764. constexpr unsigned char Abortable = 1 | 0;
  1765. DEFL_MACRO_InBl DEFL_MACRO_Outr DEFL_MACRO_Tki
  1766. }
  1767. template<typename BidirIterator,typename SizeType,typename RandomAccessIterator>
  1768. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1769. Deflate(BidirIterator&& begin,SizeType&& length,RandomAccessIterator&& target,DeflateTrackOutSize)
  1770. {
  1771. constexpr unsigned char Abortable = 1 | 0;
  1772. DEFL_MACRO_InBl DEFL_MACRO_Outr DEFL_MACRO_Tko
  1773. }
  1774. template<typename BidirIterator,typename SizeType,typename RandomAccessIterator>
  1775. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsRandomAccessIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1776. Deflate(BidirIterator&& begin,SizeType&& length,RandomAccessIterator&& target,DeflateTrackBothSize)
  1777. {
  1778. constexpr unsigned char Abortable = 1 | 0;
  1779. DEFL_MACRO_InBl DEFL_MACRO_Outr DEFL_MACRO_Tkb
  1780. }
  1781. template<typename BidirIterator,typename SizeType,typename RandomAccessIterator,typename SizeType2>
  1782. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsRandomAccessIterator && DeflIsSizeType2, int>
  1783. Deflate(BidirIterator&& begin,SizeType&& length,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackNoSize = {})
  1784. {
  1785. constexpr unsigned char Abortable = 1 | 2;
  1786. DEFL_MACRO_InBl DEFL_MACRO_Outrl DEFL_MACRO_Tk0
  1787. }
  1788. template<typename BidirIterator,typename SizeType,typename RandomAccessIterator,typename SizeType2>
  1789. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::uint_fast64_t>>
  1790. Deflate(BidirIterator&& begin,SizeType&& length,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackInSize)
  1791. {
  1792. constexpr unsigned char Abortable = 1 | 2;
  1793. DEFL_MACRO_InBl DEFL_MACRO_Outrl DEFL_MACRO_Tki
  1794. }
  1795. template<typename BidirIterator,typename SizeType,typename RandomAccessIterator,typename SizeType2>
  1796. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::uint_fast64_t>>
  1797. Deflate(BidirIterator&& begin,SizeType&& length,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackOutSize)
  1798. {
  1799. constexpr unsigned char Abortable = 1 | 2;
  1800. DEFL_MACRO_InBl DEFL_MACRO_Outrl DEFL_MACRO_Tko
  1801. }
  1802. template<typename BidirIterator,typename SizeType,typename RandomAccessIterator,typename SizeType2>
  1803. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1804. Deflate(BidirIterator&& begin,SizeType&& length,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackBothSize)
  1805. {
  1806. constexpr unsigned char Abortable = 1 | 2;
  1807. DEFL_MACRO_InBl DEFL_MACRO_Outrl DEFL_MACRO_Tkb
  1808. }
  1809. template<typename BidirIterator,typename SizeType,typename RandomAccessIterator>
  1810. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsRandomAccessIterator, int>
  1811. Deflate(BidirIterator&& begin,SizeType&& length,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackNoSize = {})
  1812. {
  1813. constexpr unsigned char Abortable = 1 | 2;
  1814. DEFL_MACRO_InBl DEFL_MACRO_Outr2 DEFL_MACRO_Tk0
  1815. }
  1816. template<typename BidirIterator,typename SizeType,typename RandomAccessIterator>
  1817. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1818. Deflate(BidirIterator&& begin,SizeType&& length,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackInSize)
  1819. {
  1820. constexpr unsigned char Abortable = 1 | 2;
  1821. DEFL_MACRO_InBl DEFL_MACRO_Outr2 DEFL_MACRO_Tki
  1822. }
  1823. template<typename BidirIterator,typename SizeType,typename RandomAccessIterator>
  1824. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1825. Deflate(BidirIterator&& begin,SizeType&& length,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackOutSize)
  1826. {
  1827. constexpr unsigned char Abortable = 1 | 2;
  1828. DEFL_MACRO_InBl DEFL_MACRO_Outr2 DEFL_MACRO_Tko
  1829. }
  1830. template<typename BidirIterator,typename SizeType,typename RandomAccessIterator>
  1831. std::enable_if_t<DeflIsBidirIterator && DeflIsSizeType && DeflIsRandomAccessIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1832. Deflate(BidirIterator&& begin,SizeType&& length,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackBothSize)
  1833. {
  1834. constexpr unsigned char Abortable = 1 | 2;
  1835. DEFL_MACRO_InBl DEFL_MACRO_Outr2 DEFL_MACRO_Tkb
  1836. }
  1837. template<typename ForwardIterator,typename OutputFunctor,typename WindowFunctor>
  1838. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputFunctor && DeflIsWindowFunctor, int>
  1839. Deflate(ForwardIterator&& begin,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackNoSize = {})
  1840. {
  1841. constexpr unsigned char Abortable = 0 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1842. DEFL_MACRO_InF DEFL_MACRO_Tk0
  1843. }
  1844. template<typename ForwardIterator,typename OutputFunctor,typename WindowFunctor>
  1845. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::uint_fast64_t>>
  1846. Deflate(ForwardIterator&& begin,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackInSize)
  1847. {
  1848. constexpr unsigned char Abortable = 0 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1849. DEFL_MACRO_InF DEFL_MACRO_Tki
  1850. }
  1851. template<typename ForwardIterator,typename OutputFunctor,typename WindowFunctor>
  1852. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::uint_fast64_t>>
  1853. Deflate(ForwardIterator&& begin,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackOutSize)
  1854. {
  1855. constexpr unsigned char Abortable = 0 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1856. DEFL_MACRO_InF DEFL_MACRO_Tko
  1857. }
  1858. template<typename ForwardIterator,typename OutputFunctor,typename WindowFunctor>
  1859. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1860. Deflate(ForwardIterator&& begin,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackBothSize)
  1861. {
  1862. constexpr unsigned char Abortable = 0 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  1863. DEFL_MACRO_InF DEFL_MACRO_Tkb
  1864. }
  1865. template<typename ForwardIterator,typename OutputFunctor>
  1866. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputFunctor, int>
  1867. Deflate(ForwardIterator&& begin,OutputFunctor&& output_orig,DeflateTrackNoSize = {})
  1868. {
  1869. constexpr unsigned char Abortable = 0 | DeflOutputAbortable_OutputFunctor;
  1870. DEFL_MACRO_InF DEFL_MACRO_Outf DEFL_MACRO_Tk0
  1871. }
  1872. template<typename ForwardIterator,typename OutputFunctor>
  1873. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputFunctor, std::pair<int, std::uint_fast64_t>>
  1874. Deflate(ForwardIterator&& begin,OutputFunctor&& output_orig,DeflateTrackInSize)
  1875. {
  1876. constexpr unsigned char Abortable = 0 | DeflOutputAbortable_OutputFunctor;
  1877. DEFL_MACRO_InF DEFL_MACRO_Outf DEFL_MACRO_Tki
  1878. }
  1879. template<typename ForwardIterator,typename OutputFunctor>
  1880. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputFunctor, std::pair<int, std::uint_fast64_t>>
  1881. Deflate(ForwardIterator&& begin,OutputFunctor&& output_orig,DeflateTrackOutSize)
  1882. {
  1883. constexpr unsigned char Abortable = 0 | DeflOutputAbortable_OutputFunctor;
  1884. DEFL_MACRO_InF DEFL_MACRO_Outf DEFL_MACRO_Tko
  1885. }
  1886. template<typename ForwardIterator,typename OutputFunctor>
  1887. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputFunctor, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1888. Deflate(ForwardIterator&& begin,OutputFunctor&& output_orig,DeflateTrackBothSize)
  1889. {
  1890. constexpr unsigned char Abortable = 0 | DeflOutputAbortable_OutputFunctor;
  1891. DEFL_MACRO_InF DEFL_MACRO_Outf DEFL_MACRO_Tkb
  1892. }
  1893. template<typename ForwardIterator,typename OutputIterator>
  1894. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputIterator, int>
  1895. Deflate(ForwardIterator&& begin,OutputIterator&& target,DeflateTrackNoSize = {})
  1896. {
  1897. constexpr unsigned char Abortable = 0 | 0;
  1898. DEFL_MACRO_InF DEFL_MACRO_OutI DEFL_MACRO_Tk0
  1899. }
  1900. template<typename ForwardIterator,typename OutputIterator>
  1901. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputIterator, std::pair<int, std::uint_fast64_t>>
  1902. Deflate(ForwardIterator&& begin,OutputIterator&& target,DeflateTrackInSize)
  1903. {
  1904. constexpr unsigned char Abortable = 0 | 0;
  1905. DEFL_MACRO_InF DEFL_MACRO_OutI DEFL_MACRO_Tki
  1906. }
  1907. template<typename ForwardIterator,typename OutputIterator>
  1908. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputIterator, std::pair<int, std::uint_fast64_t>>
  1909. Deflate(ForwardIterator&& begin,OutputIterator&& target,DeflateTrackOutSize)
  1910. {
  1911. constexpr unsigned char Abortable = 0 | 0;
  1912. DEFL_MACRO_InF DEFL_MACRO_OutI DEFL_MACRO_Tko
  1913. }
  1914. template<typename ForwardIterator,typename OutputIterator>
  1915. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1916. Deflate(ForwardIterator&& begin,OutputIterator&& target,DeflateTrackBothSize)
  1917. {
  1918. constexpr unsigned char Abortable = 0 | 0;
  1919. DEFL_MACRO_InF DEFL_MACRO_OutI DEFL_MACRO_Tkb
  1920. }
  1921. template<typename ForwardIterator,typename RandomAccessIterator>
  1922. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator, int>
  1923. Deflate(ForwardIterator&& begin,RandomAccessIterator&& target,DeflateTrackNoSize = {})
  1924. {
  1925. constexpr unsigned char Abortable = 0 | 0;
  1926. DEFL_MACRO_InF DEFL_MACRO_Outr DEFL_MACRO_Tk0
  1927. }
  1928. template<typename ForwardIterator,typename RandomAccessIterator>
  1929. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1930. Deflate(ForwardIterator&& begin,RandomAccessIterator&& target,DeflateTrackInSize)
  1931. {
  1932. constexpr unsigned char Abortable = 0 | 0;
  1933. DEFL_MACRO_InF DEFL_MACRO_Outr DEFL_MACRO_Tki
  1934. }
  1935. template<typename ForwardIterator,typename RandomAccessIterator>
  1936. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1937. Deflate(ForwardIterator&& begin,RandomAccessIterator&& target,DeflateTrackOutSize)
  1938. {
  1939. constexpr unsigned char Abortable = 0 | 0;
  1940. DEFL_MACRO_InF DEFL_MACRO_Outr DEFL_MACRO_Tko
  1941. }
  1942. template<typename ForwardIterator,typename RandomAccessIterator>
  1943. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1944. Deflate(ForwardIterator&& begin,RandomAccessIterator&& target,DeflateTrackBothSize)
  1945. {
  1946. constexpr unsigned char Abortable = 0 | 0;
  1947. DEFL_MACRO_InF DEFL_MACRO_Outr DEFL_MACRO_Tkb
  1948. }
  1949. template<typename ForwardIterator,typename RandomAccessIterator,typename SizeType2>
  1950. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator && DeflIsSizeType2, int>
  1951. Deflate(ForwardIterator&& begin,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackNoSize = {})
  1952. {
  1953. constexpr unsigned char Abortable = 0 | 2;
  1954. DEFL_MACRO_InF DEFL_MACRO_Outrl DEFL_MACRO_Tk0
  1955. }
  1956. template<typename ForwardIterator,typename RandomAccessIterator,typename SizeType2>
  1957. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::uint_fast64_t>>
  1958. Deflate(ForwardIterator&& begin,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackInSize)
  1959. {
  1960. constexpr unsigned char Abortable = 0 | 2;
  1961. DEFL_MACRO_InF DEFL_MACRO_Outrl DEFL_MACRO_Tki
  1962. }
  1963. template<typename ForwardIterator,typename RandomAccessIterator,typename SizeType2>
  1964. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::uint_fast64_t>>
  1965. Deflate(ForwardIterator&& begin,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackOutSize)
  1966. {
  1967. constexpr unsigned char Abortable = 0 | 2;
  1968. DEFL_MACRO_InF DEFL_MACRO_Outrl DEFL_MACRO_Tko
  1969. }
  1970. template<typename ForwardIterator,typename RandomAccessIterator,typename SizeType2>
  1971. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  1972. Deflate(ForwardIterator&& begin,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackBothSize)
  1973. {
  1974. constexpr unsigned char Abortable = 0 | 2;
  1975. DEFL_MACRO_InF DEFL_MACRO_Outrl DEFL_MACRO_Tkb
  1976. }
  1977. template<typename ForwardIterator,typename RandomAccessIterator>
  1978. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator, int>
  1979. Deflate(ForwardIterator&& begin,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackNoSize = {})
  1980. {
  1981. constexpr unsigned char Abortable = 0 | 2;
  1982. DEFL_MACRO_InF DEFL_MACRO_Outr2 DEFL_MACRO_Tk0
  1983. }
  1984. template<typename ForwardIterator,typename RandomAccessIterator>
  1985. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1986. Deflate(ForwardIterator&& begin,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackInSize)
  1987. {
  1988. constexpr unsigned char Abortable = 0 | 2;
  1989. DEFL_MACRO_InF DEFL_MACRO_Outr2 DEFL_MACRO_Tki
  1990. }
  1991. template<typename ForwardIterator,typename RandomAccessIterator>
  1992. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  1993. Deflate(ForwardIterator&& begin,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackOutSize)
  1994. {
  1995. constexpr unsigned char Abortable = 0 | 2;
  1996. DEFL_MACRO_InF DEFL_MACRO_Outr2 DEFL_MACRO_Tko
  1997. }
  1998. template<typename ForwardIterator,typename RandomAccessIterator>
  1999. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  2000. Deflate(ForwardIterator&& begin,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackBothSize)
  2001. {
  2002. constexpr unsigned char Abortable = 0 | 2;
  2003. DEFL_MACRO_InF DEFL_MACRO_Outr2 DEFL_MACRO_Tkb
  2004. }
  2005. template<typename ForwardIterator,typename OutputFunctor,typename WindowFunctor>
  2006. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputFunctor && DeflIsWindowFunctor, int>
  2007. Deflate(ForwardIterator&& begin,ForwardIterator&& end,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackNoSize = {})
  2008. {
  2009. constexpr unsigned char Abortable = 1 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  2010. DEFL_MACRO_InF2 DEFL_MACRO_Tk0
  2011. }
  2012. template<typename ForwardIterator,typename OutputFunctor,typename WindowFunctor>
  2013. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::uint_fast64_t>>
  2014. Deflate(ForwardIterator&& begin,ForwardIterator&& end,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackInSize)
  2015. {
  2016. constexpr unsigned char Abortable = 1 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  2017. DEFL_MACRO_InF2 DEFL_MACRO_Tki
  2018. }
  2019. template<typename ForwardIterator,typename OutputFunctor,typename WindowFunctor>
  2020. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::uint_fast64_t>>
  2021. Deflate(ForwardIterator&& begin,ForwardIterator&& end,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackOutSize)
  2022. {
  2023. constexpr unsigned char Abortable = 1 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  2024. DEFL_MACRO_InF2 DEFL_MACRO_Tko
  2025. }
  2026. template<typename ForwardIterator,typename OutputFunctor,typename WindowFunctor>
  2027. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputFunctor && DeflIsWindowFunctor, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  2028. Deflate(ForwardIterator&& begin,ForwardIterator&& end,OutputFunctor&& output,WindowFunctor&& outputcopy,DeflateTrackBothSize)
  2029. {
  2030. constexpr unsigned char Abortable = 1 | (DeflOutputAbortable_OutputFunctor & DeflOutputAbortable_WindowFunctor);
  2031. DEFL_MACRO_InF2 DEFL_MACRO_Tkb
  2032. }
  2033. template<typename ForwardIterator,typename OutputFunctor>
  2034. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputFunctor, int>
  2035. Deflate(ForwardIterator&& begin,ForwardIterator&& end,OutputFunctor&& output_orig,DeflateTrackNoSize = {})
  2036. {
  2037. constexpr unsigned char Abortable = 1 | DeflOutputAbortable_OutputFunctor;
  2038. DEFL_MACRO_InF2 DEFL_MACRO_Outf DEFL_MACRO_Tk0
  2039. }
  2040. template<typename ForwardIterator,typename OutputFunctor>
  2041. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputFunctor, std::pair<int, std::uint_fast64_t>>
  2042. Deflate(ForwardIterator&& begin,ForwardIterator&& end,OutputFunctor&& output_orig,DeflateTrackInSize)
  2043. {
  2044. constexpr unsigned char Abortable = 1 | DeflOutputAbortable_OutputFunctor;
  2045. DEFL_MACRO_InF2 DEFL_MACRO_Outf DEFL_MACRO_Tki
  2046. }
  2047. template<typename ForwardIterator,typename OutputFunctor>
  2048. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputFunctor, std::pair<int, std::uint_fast64_t>>
  2049. Deflate(ForwardIterator&& begin,ForwardIterator&& end,OutputFunctor&& output_orig,DeflateTrackOutSize)
  2050. {
  2051. constexpr unsigned char Abortable = 1 | DeflOutputAbortable_OutputFunctor;
  2052. DEFL_MACRO_InF2 DEFL_MACRO_Outf DEFL_MACRO_Tko
  2053. }
  2054. template<typename ForwardIterator,typename OutputFunctor>
  2055. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputFunctor, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  2056. Deflate(ForwardIterator&& begin,ForwardIterator&& end,OutputFunctor&& output_orig,DeflateTrackBothSize)
  2057. {
  2058. constexpr unsigned char Abortable = 1 | DeflOutputAbortable_OutputFunctor;
  2059. DEFL_MACRO_InF2 DEFL_MACRO_Outf DEFL_MACRO_Tkb
  2060. }
  2061. template<typename ForwardIterator,typename OutputIterator>
  2062. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputIterator, int>
  2063. Deflate(ForwardIterator&& begin,ForwardIterator&& end,OutputIterator&& target,DeflateTrackNoSize = {})
  2064. {
  2065. constexpr unsigned char Abortable = 1 | 0;
  2066. DEFL_MACRO_InF2 DEFL_MACRO_OutI DEFL_MACRO_Tk0
  2067. }
  2068. template<typename ForwardIterator,typename OutputIterator>
  2069. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputIterator, std::pair<int, std::uint_fast64_t>>
  2070. Deflate(ForwardIterator&& begin,ForwardIterator&& end,OutputIterator&& target,DeflateTrackInSize)
  2071. {
  2072. constexpr unsigned char Abortable = 1 | 0;
  2073. DEFL_MACRO_InF2 DEFL_MACRO_OutI DEFL_MACRO_Tki
  2074. }
  2075. template<typename ForwardIterator,typename OutputIterator>
  2076. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputIterator, std::pair<int, std::uint_fast64_t>>
  2077. Deflate(ForwardIterator&& begin,ForwardIterator&& end,OutputIterator&& target,DeflateTrackOutSize)
  2078. {
  2079. constexpr unsigned char Abortable = 1 | 0;
  2080. DEFL_MACRO_InF2 DEFL_MACRO_OutI DEFL_MACRO_Tko
  2081. }
  2082. template<typename ForwardIterator,typename OutputIterator>
  2083. std::enable_if_t<DeflIsForwardIterator && DeflIsOutputIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  2084. Deflate(ForwardIterator&& begin,ForwardIterator&& end,OutputIterator&& target,DeflateTrackBothSize)
  2085. {
  2086. constexpr unsigned char Abortable = 1 | 0;
  2087. DEFL_MACRO_InF2 DEFL_MACRO_OutI DEFL_MACRO_Tkb
  2088. }
  2089. template<typename ForwardIterator,typename RandomAccessIterator>
  2090. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator, int>
  2091. Deflate(ForwardIterator&& begin,ForwardIterator&& end,RandomAccessIterator&& target,DeflateTrackNoSize = {})
  2092. {
  2093. constexpr unsigned char Abortable = 1 | 0;
  2094. DEFL_MACRO_InF2 DEFL_MACRO_Outr DEFL_MACRO_Tk0
  2095. }
  2096. template<typename ForwardIterator,typename RandomAccessIterator>
  2097. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  2098. Deflate(ForwardIterator&& begin,ForwardIterator&& end,RandomAccessIterator&& target,DeflateTrackInSize)
  2099. {
  2100. constexpr unsigned char Abortable = 1 | 0;
  2101. DEFL_MACRO_InF2 DEFL_MACRO_Outr DEFL_MACRO_Tki
  2102. }
  2103. template<typename ForwardIterator,typename RandomAccessIterator>
  2104. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  2105. Deflate(ForwardIterator&& begin,ForwardIterator&& end,RandomAccessIterator&& target,DeflateTrackOutSize)
  2106. {
  2107. constexpr unsigned char Abortable = 1 | 0;
  2108. DEFL_MACRO_InF2 DEFL_MACRO_Outr DEFL_MACRO_Tko
  2109. }
  2110. template<typename ForwardIterator,typename RandomAccessIterator>
  2111. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  2112. Deflate(ForwardIterator&& begin,ForwardIterator&& end,RandomAccessIterator&& target,DeflateTrackBothSize)
  2113. {
  2114. constexpr unsigned char Abortable = 1 | 0;
  2115. DEFL_MACRO_InF2 DEFL_MACRO_Outr DEFL_MACRO_Tkb
  2116. }
  2117. template<typename ForwardIterator,typename RandomAccessIterator,typename SizeType2>
  2118. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator && DeflIsSizeType2, int>
  2119. Deflate(ForwardIterator&& begin,ForwardIterator&& end,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackNoSize = {})
  2120. {
  2121. constexpr unsigned char Abortable = 1 | 2;
  2122. DEFL_MACRO_InF2 DEFL_MACRO_Outrl DEFL_MACRO_Tk0
  2123. }
  2124. template<typename ForwardIterator,typename RandomAccessIterator,typename SizeType2>
  2125. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::uint_fast64_t>>
  2126. Deflate(ForwardIterator&& begin,ForwardIterator&& end,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackInSize)
  2127. {
  2128. constexpr unsigned char Abortable = 1 | 2;
  2129. DEFL_MACRO_InF2 DEFL_MACRO_Outrl DEFL_MACRO_Tki
  2130. }
  2131. template<typename ForwardIterator,typename RandomAccessIterator,typename SizeType2>
  2132. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::uint_fast64_t>>
  2133. Deflate(ForwardIterator&& begin,ForwardIterator&& end,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackOutSize)
  2134. {
  2135. constexpr unsigned char Abortable = 1 | 2;
  2136. DEFL_MACRO_InF2 DEFL_MACRO_Outrl DEFL_MACRO_Tko
  2137. }
  2138. template<typename ForwardIterator,typename RandomAccessIterator,typename SizeType2>
  2139. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator && DeflIsSizeType2, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  2140. Deflate(ForwardIterator&& begin,ForwardIterator&& end,RandomAccessIterator&& target,SizeType2&& target_limit,DeflateTrackBothSize)
  2141. {
  2142. constexpr unsigned char Abortable = 1 | 2;
  2143. DEFL_MACRO_InF2 DEFL_MACRO_Outrl DEFL_MACRO_Tkb
  2144. }
  2145. template<typename ForwardIterator,typename RandomAccessIterator>
  2146. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator, int>
  2147. Deflate(ForwardIterator&& begin,ForwardIterator&& end,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackNoSize = {})
  2148. {
  2149. constexpr unsigned char Abortable = 1 | 2;
  2150. DEFL_MACRO_InF2 DEFL_MACRO_Outr2 DEFL_MACRO_Tk0
  2151. }
  2152. template<typename ForwardIterator,typename RandomAccessIterator>
  2153. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  2154. Deflate(ForwardIterator&& begin,ForwardIterator&& end,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackInSize)
  2155. {
  2156. constexpr unsigned char Abortable = 1 | 2;
  2157. DEFL_MACRO_InF2 DEFL_MACRO_Outr2 DEFL_MACRO_Tki
  2158. }
  2159. template<typename ForwardIterator,typename RandomAccessIterator>
  2160. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator, std::pair<int, std::uint_fast64_t>>
  2161. Deflate(ForwardIterator&& begin,ForwardIterator&& end,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackOutSize)
  2162. {
  2163. constexpr unsigned char Abortable = 1 | 2;
  2164. DEFL_MACRO_InF2 DEFL_MACRO_Outr2 DEFL_MACRO_Tko
  2165. }
  2166. template<typename ForwardIterator,typename RandomAccessIterator>
  2167. std::enable_if_t<DeflIsForwardIterator && DeflIsRandomAccessIterator, std::pair<int, std::pair<std::uint_fast64_t,std::uint_fast64_t>>>
  2168. Deflate(ForwardIterator&& begin,ForwardIterator&& end,RandomAccessIterator&& target_begin,RandomAccessIterator&& target_end,DeflateTrackBothSize)
  2169. {
  2170. constexpr unsigned char Abortable = 1 | 2;
  2171. DEFL_MACRO_InF2 DEFL_MACRO_Outr2 DEFL_MACRO_Tkb
  2172. }
  2173. #undef DEFL_MACRO_Inf
  2174. #undef DEFL_MACRO_InI
  2175. #undef DEFL_MACRO_InI2
  2176. #undef DEFL_MACRO_InIl
  2177. #undef DEFL_MACRO_InBl
  2178. #undef DEFL_MACRO_InF
  2179. #undef DEFL_MACRO_InF2
  2180. #undef DEFL_MACRO_Outf
  2181. #undef DEFL_MACRO_OutI
  2182. #undef DEFL_MACRO_Outr
  2183. #undef DEFL_MACRO_Outrl
  2184. #undef DEFL_MACRO_Outr2
  2185. #undef DEFL_MACRO_Tk0
  2186. #undef DEFL_MACRO_Tki
  2187. #undef DEFL_MACRO_Tko
  2188. #undef DEFL_MACRO_Tkb
  2189. #undef DeflDeclWindow
  2190. #undef DeflIsWindowFunctor
  2191. #undef DeflIsInputFunctor
  2192. #undef DeflIsWindowFunctor
  2193. #undef DeflIsBacktrackFunctor
  2194. #undef DeflIsRandomAccessIterator
  2195. #undef DeflIsForwardIterator
  2196. #undef DeflIsBidirIterator
  2197. #undef DeflIsInputIterator
  2198. #undef DeflIsOutputIterator
  2199. #undef DeflIsSizeType
  2200. #undef DeflIsSizeType2
  2201. #undef DeflInputAbortable_InputFunctor
  2202. #undef DeflOutputAbortable_OutputFunctor
  2203. #undef DeflOutputAbortable_WindowFunctor