A large pile with the right types and ratio of ingredients will (should) create enough heat to destroy the majority of weeds. If the pile is smaller, it might not heat up enough and weed seeds can then survive even through a long composting process.
My piles are so small that they don't heat up much. I rely on a few things.
1. I already have so many weeds that a few more seeds won't make it any worse.
2. I figure that some weed seeds will sprout during the composting process, as I turn it and keep it moist. I certainly see a lot of peas and Brassica seeds sprout when I toss pea plants with moldy pods or greens that have gone to seed.
3. Hopefully, worms will eat some weed seeds and some will rot.
4. When I spread compost, I also scratch it in so it stays moist and doesn't die. Buried weed seeds won't sprout until they get turned up to the surface.
5. I try to mulch every bed with coarse bark chips. They keep the weeds from sprouting, and seem to make it easier to pull out entire roots when they do sprout. I suppose that's because they keep the soil moist and loose.
That said, I WOULDN'T compost weeds that had gone all the way to seed, IF I had enough other sources of organic matter to make enough compost. I'm always short on compost. I could use three times as much as I can make.
If I had a 'weed torch", I would crisp the seedheads before harvesting the weeds.