President Obama won’t explicitly say Donald Trump is on the wrong side of history, but surely it’s what he believes.

The president basically thinks anyone who gets in his way is transgressing the larger forces of history with a capital H. During the 2008 campaign, he declared Sen. John McCain “on the wrong side of history right now” (the “right now” was a generous touch — allowing for the possibility McCain might get right with History at some future, undetermined date).

Obama has returned to this phrase and argument obsessively throughout his time in office. It is deeply embedded in his, and the larger progressive, mind — and indirectly contributed to the left’s catastrophic defeat on Nov. 8.

The notion that History takes sides ultimately traces back to the philosopher G.W.F. Hegel and borrows heavily from the (genuine and very hard-won) moral capital of the abolitionists and the civil rights movement.

Obama is given to quoting Martin Luther King for the proposition that the arc of the moral universe bends toward justice. Whoever is deemed to be on “the wrong side of history” by progressives is always loosely associated with the opprobrium directed toward the Southern Fire-Eaters and the defenders of Jim Crow.

This means the left wields History as a weapon and makes it an occasion for constant self-congratulation. But there’s a downside.

For the left, History isn’t a vast, unpredictable, untameable force, but just like someone who might be standing in line next to you at Whole Foods. History is a board member of Planned Parenthood. It reads the Huffington Post and Vox, and follows Lena Dunham on Twitter.

It really cares whether transgender people are allowed to use the appropriate bathroom. History was probably hanging out at the Javits Center on election night and collapsed into a puddle of tears right around the time Wisconsin was called.

The political dangers of this point of view should be obvious:

It assumes that certain classes of people are retrograde. Why would Democrats bother to try to appeal to working-class white voters if they’re stamped with the disapproval of History?

According to Politico’s reporting, when poor Bill Clinton piped up at strategy sessions and wondered why Hillary’s campaign wasn’t trying to appeal to these voters, he was treated as an embarrassing relic, out of touch with the inexorable tide of the future.

It becomes a warrant for all manner of overreach. History evidently favored trying to get nuns to sign up for contraceptives they didn’t want — and morally opposed — and forcing small businesses to bake cakes for gay weddings. There was really no amount of coercion on behalf of social liberalism that History wouldn’t heartily embrace.

And, if History is thought to have an ascendant electoral coalition (and a hell of a data operation), it creates an unjustified sense of electoral inevitably. This is what the theorists of the “emerging Democratic majority,” and most of the pundits on the left, bought into.

Sean Trende of RealClearPolitics has long been a scourge of this thesis, rightly pointing out the allegedly unstoppable coalition was vulnerable to relatively small changes in voting behavior and turnout, and of course larger events.

All that said, the evidence was pretty good for the proposition that welfare-state programs, once ensconced, could never be reversed and therefore must enjoy the approval of History. This assumption pervaded the ObamaCare debate. Upon passage of his health care law, Obama said, “Tonight, we answered the call of history.”

Harry Reid lambasted Republicans for not “joining us on the right side of history” and compared them to — of course — defenders of slavery.

In retrospect, History might not have been so enamored of sprawling laws based on poorly thought-through economic premises, and might have looked more kindly on other, less disruptive means of getting more people insured. Regardless, when Republicans pass a repeal bill in one form or another early next year, it will constitute their most significant rollback of the welfare state ever.

Another progressive assumption is that the nation-state is bound inevitably to decline in importance, as supranational institutions like the European Union grow in power and cross-border migrations increase. In a trip to Germany in April, Obama deemed Angela Merkel’s policy of welcoming a massive wave of migrants as “on the right side of history.”

Never mind that its recklessness has caused a political backlash in Europe that’s still brewing. Obama believed the same of his own latitudinarian views on immigration, apparently never imagining how many people might consider it progress to tighten our borders rather than render them more porous.

Now, a president who so confidently associated himself and his cause with the tide of the future has presided over a political wipeout that’ll send much of his legacy into the dustbin. If nothing else, History has a keen sense of humor.