Yes, cost, but not necessarily in large numbers. The idea of the TD was mainly (since inception) a corps-level unit or formation for blocking large armoured forces (stiffen a defence, counter-penetration, guard, etc). There would never have been many.
Repeating what I've written before:
"TD" as a doctrine should apply to any system which will serve (tanks, anti-tank guns, anti-armour missiles, attack helicopters, etc), which means it is really just a part of each of the doctrines of forces employing each of those. "TD" as a weapon is a bit too bespoke unless a nation is on the strategic defensive against massive mechanized forces (or expects to be) and is pressed for resources. "Can't get a heavy enough gun into a turret" is no longer really a problem that requires another solution.
Tanks and helicopters are more versatile; towed guns are nigh-obsolete (survivability and impractical size); missiles have the advantages of isolation of launcher from controller and guidance (thus NLOS capability).
Similar arguments apply to "assault gun", which a fair number of TD were employed as from time to time. I figure once everyone figured out how to put a high-powered 75 mm or 3" gun into a turret the TD and assault gun were no longer needed, except as expedients to get more guns into an army somewhat desperately on the strategic defensive.
Trying to look forward:
The weight of a platform must have already practically topped out, if only because of civil engineering limitations (eg. bridges permanent and temporary). Within that weight, the guns they can mount are already able to kill their peers. Some stand-off detonation protection (eg. against missiles) is awkward to arrange, but possible. Wheels and tracks both seem to have reached the limits of how far they can be exploited long ago. There is no obvious technology that can provide a non-fragile VTOL "tank" (ie. to skip past wheels/tracks) except at absurd levels of fuel consumption.
I keep thinking that if the munitions can overpower the kinetic protection and the problem has moved instead into the realm of "must not be acquired", future tanks might as well be lighter (and maybe there are some techniques for improving crew survival which have not been exhausted).
What is needed to enable armoured operations has not changed: first win air dominance and artillery dominance so that the other guy is too busy with other things to be able to mount some kind of drone swarm counter-measure to combined arms moving into his turf.
The Tank Destroyer and the Assault Gun I always perceived as the continuation of the old Field Guns that served on line with the Sabres and the Rifles. They brought a Direct Fire heavy weight round to the fight that could be judiciously applied against discrete Line of Sight targets.
The 25 pdr of the Field Artillery served more as a Howitzer than a Gun although it was nominally a Gun-Howitzer. Field Gunnery in the pre 1914 sense, was the domain of the 6 and 17 pdrs and the 88s.
A TD was a field gun that only killed tanks, by intention, but in practice, like every other gun, was used on every target in its sights.
Now DFS has taken on a whole new meaning when the gunner can pause his round in mid-flight, reconsider his target, and redirect to a preferred target with precision.
Worse/Better the target and the gunner need not be in LOS of each other.
Worser/Betterer the gunner's round may be co-opted by the gunner's commander in mid-flight and redirected for him.
The Brimstone 3, launched from a helicopter has a range of 60 km but only delivers a 6.3 kg warhead. It was meant for launching in salvos against regiments of tanks. Now it is being used to plink tanks from 60 km away.
The new range of Low Cost Cruise Missiles, like L3 Harris's Red Wolf (350 km and an 11 kg payload), or Anduril's Barracuda series (16 kg for 222 km, 16 kg for 370 km, 55 kg for 926 km) or Kratos's Ragnarok (36 kg over 926 km) .... they suggest plinking gun positions from 500 to 1000 km away. But the time of flight is measured in hours and not the seconds needed by an infanteer in a hole.
So what might rounds like that excel at?
They could sacrifice some of that range for endurance and establish a cab rank circling above the infanteer waiting for her to pick a target.
Or
They could be used at extreme range, timed to arrive when buddy steps out of his front door for his regular morning run. And leave his house standing.