Companies that provide end-of-life services stand to benefit from what boils down to a macabre version of high demand as the U.S. baby boom generation approaches its seventies.

Roughly 2.6 million people died in the United States in 2014, up from 2.47 million in 2010, according to the Centers for Disease Control, and demographic trends show the number will continue to rise.

Service Corporation International, which operates funeral homes and cemeteries, has been a prime beneficiary of the aging population. Its shares had risen 27.7 percent in 2015 through Thursday's close.

Among smaller peers, StoneMor Partners was up 16.4 percent year-to-date, easily outpacing the S&P 500's 3 percent rise. Carriage Services was up 19.4 percent and on track for its seventh straight annual increase.

"The demographic trend will probably last a couple of decades," said Charles Sizemore, chief investment officer of Sizemore Capital Management in Dallas, who owns StoneMor shares. "It's morbid, but the time will come for every boomer, and the result of that is a very good backdrop for these companies."

The biggest threat is not life-extending advances in medical technology, but instead a growing trend toward cremation, which is cheaper, Sizemore said. According to the National Funeral Directors Association, the median U.S. funeral cost $7,045 in 2012, the most recent year for which data is available. A cremation can cost less than half of that.

The NFDA projects 48.2 percent of 2015 services will be cremations while 45.8 percent will be burials. By 2030, though, it estimates that 70.6 percent of services will be cremations.

"An urn is certainly cheaper than a burial plot," Sizemore said, "but even if a larger proportion opts for cremation, there will be business for everyone, given the sheer number of deaths coming down the pipeline."