Donald Trump speaks during the CNBC primary debate Tuesday. (Robyn Beck/AFP/Getty Images)

Tuesday night's GOP primary debate focused exclusively on national security, with one interesting exception. Donald Trump, asked for his views on the war in Iraq, pivoted the conversation to the subject of infrastructure.

"We've spent $4 trillion trying to topple various people," Trump said. "If we could've spent that $4 trillion in the United States to fix our roads, our bridges and all of the other problems -- our airports and all of the other problems we've had -- we would've been a lot better off. I can tell you that right now."

The real-estate magnate was not exaggerating the cost. Several researchers have come to a similar figure for the price tag associated with the wars in Iraq and Afghanistan.

[Now is the time to be an infrastructure hawk, not a deficit hawk]

And over the past several years, some federal investments in infrastructure could have saved the government money. Roads, bridges, railways and runways inevitably break down over time and must be replaced. Because of the poor overall state of the economy, the government had an opportunity to make those replacements ahead of schedule at a reduced cost.

With unemployment rates elevated in the construction sector, contractors could have cheaply found workers to do the job. And nervous investors around the world were loaning money to the federal government at negative real interest rates, meaning that they were willing to help pay for new projects in exchange for keeping their money safe on Uncle Sam's books.

Future generations will have to deal with those run-down bridges and highways eventually, likely at higher costs. The Federal Reserve is widely expected to raise interest rates Wednesday, marking improvements in the economy that would make these projects more expensive today.

[Larry Summers: Fixing America’s roads would essentially pay for itself]

Still, some of them would pay for themselves. As Wonkblog contributor and former Treasury Secretary Larry Summers has noted, rough roads beat up cars, forcing American drivers to pay more at maintenance shops than they would if they were driving on smoother pavement. In 2013, poor road conditions cost the average American driver an additional $516. It would likely be cheaper just to fix some of those roads.

Trump's argument implied the government had a few trillion dollars in cash that it spent fighting wars and that as a result nothing was left for other purposes. The wars overseas did not prevent the government from paying for road and bridge improvements, though. Congress's choice not to do so was a political decision, unconstrained by any lack of funds.

Much of the roughly $4 trillion or more the United States is expected to spend as a result of the wars hasn't been spent yet. Some of it will pay for veterans as they age and draw payments from the federal government.

Even the money that has already been spent in the Middle East is money the United States never had. Rather, Congress borrowed it -- and Congress could have borrowed more to repair the country's infrastructure.

Trump's argument came during a debate in which the candidates spent little time to talk about Americans' affairs at home. His comments drew criticism from some of his rivals on stage during CNN's primary debate in Las Vegas.

"That's exactly what President Obama said," Carly Fiorina, the former chief executive of Hewlett-Packard, said. Obama has also called on Congress to spend more on infrastructure.

Trump might have sounded like a Democrat, but maintaining the national transportation network has long been a Republican priority, as well. It was President Dwight Eisenhower who built the interstate highway system, after all.

"If we want people working in America, we got to make sure our highways and roads are modern," President George W. Bush said in 2005.