code logs -> 2024 -> Wed, 17 Jan 2024< code.20240116.log - code.20240118.log >
--- Log opened Wed Jan 17 00:00:45 2024
00:03
<@celticminstrel>
Is there no standard/Boost way to erase the type of a container in C++? Like, if I have a vector<int>, and I want a function to convert it to just a pair of iterators in a way that the code still compiles if I decide to change it to deque or list.
01:00 Vornicus [Vorn@Nightstar-ivektl.res.spectrum.com] has quit [Connection closed]
02:01 Degi_ [Degi@Nightstar-rlg593.pool.telefonica.de] has joined #code
02:02 Degi [Degi@Nightstar-5ke9ot.pool.telefonica.de] has quit [Ping timeout: 121 seconds]
02:02 Degi_ is now known as Degi
04:21 Kimo|autojoin [Kindamoody@Nightstar-pqh9gl.tbcn.telia.com] has quit [Ping timeout: 121 seconds]
04:48 Kimo|autojoin [Kindamoody@Nightstar-pqh9gl.tbcn.telia.com] has joined #code
04:48 mode/#code [+o Kimo|autojoin] by ChanServ
04:54 Kimo|autojoin [Kindamoody@Nightstar-pqh9gl.tbcn.telia.com] has quit [Ping timeout: 121 seconds]
04:59
<&McMartin>
celticminstrel: There is not, because the way C++ does Generics does not permit this to be a thing
05:00
<&McMartin>
C++ generics actually reimplement the entire class for each target type; it does not have a uniform generic reference the way Java does.
05:00
<&McMartin>
(To get Java-like behavior you implement a nontemplated void *-based version and make your templated class an extremely thin wrapper around it.)
05:36
<@celticminstrel>
All I really want is something equivalent to "unspecified iterator pointing to a T".
05:38
<@celticminstrel>
So that the container type doesn't need to be specified in the public API.
05:40
<&McMartin>
Yeah, that is just fundamentally not how the STL works
05:40
<&McMartin>
The closest you will get are that <algorithm> has stuff that takes two iterators for start and end and Does A Thing depending on what that function is
05:40
<@celticminstrel>
Boost.Range just wraps a pair of iterators, so that doesn't help either.
05:40
<&McMartin>
You're looking at writing a function that is itself templated and calls ++ or whatever to advance.
05:41
<&McMartin>
On the plus side, not only will that work on unspecified iterators, it will _also_ work on T*
05:41
<@celticminstrel>
Hmm…
05:42
<@celticminstrel>
I get the feeling this means making the virtual function(s) private/protected.
05:42
<&McMartin>
Virtuality is probably not the thing you want for this, yeah
05:42
<&McMartin>
Templated stuff -- and remember what the T in STL stands for -- are best thought of as lightly type-checked macros.
05:43
<@celticminstrel>
It's not even legal to make a template function virtual.
05:47
<&McMartin>
Yes; template functions do not properly exist until link time so it's impossible to fill out a vtable with them.
06:20 Kimo|autojoin [Kindamoody@Nightstar-pqh9gl.tbcn.telia.com] has joined #code
06:20 mode/#code [+o Kimo|autojoin] by ChanServ
06:24 Kimo|autojoin [Kindamoody@Nightstar-pqh9gl.tbcn.telia.com] has quit [Ping timeout: 121 seconds]
06:59 Kimo|autojoin [Kindamoody@Nightstar-pqh9gl.tbcn.telia.com] has joined #code
06:59 mode/#code [+o Kimo|autojoin] by ChanServ
09:09 Vornicus [Vorn@Nightstar-ivektl.res.spectrum.com] has joined #code
09:09 mode/#code [+qo Vornicus Vornicus] by ChanServ
10:35 Emmy [Emmy@Nightstar-qo29c7.fixed.kpn.net] has joined #code
23:53 Emmy [Emmy@Nightstar-qo29c7.fixed.kpn.net] has quit [Ping timeout: 121 seconds]
--- Log closed Thu Jan 18 00:00:46 2024
code logs -> 2024 -> Wed, 17 Jan 2024< code.20240116.log - code.20240118.log >

[ Latest log file ]