I don't think this will work in the case of filter being unused. I'm getting the following compilation error:
In file included from merkleblock.cpp:6:0:
merkleblock.h: In constructor ‘CMerkleBlock::CMerkleBlock(const CBlock&, const std::set<uint256>&)’:
merkleblock.h:145:93: error: invalid initialization of non-const reference of type ‘CBloomFilter&’ from an rvalue of type ‘CBloomFilter’
CMerkleBlock(const CBlock& block, const std::set<uint256>& txids) : CMerkleBlock(block, CBloomFilter(), txids) {}
^~~~~~~~~~~~~~
merkleblock.h:148:5: note: initializing argument 2 of ‘CMerkleBlock::CMerkleBlock(const CBlock&, CBloomFilter&, const std::set<uint256>&)’
CMerkleBlock(const CBlock& block, CBloomFilter& filter, const std::set<uint256>& txids);
^~~~~~~~~~~~
Apparently we can't create an unnamed, non-const CBloomFilter reference from an rvalue. I'm not sure how to avoid this when using constructor delegation.