So, after a bit of a struggle trying to dust off my sed skills, I was able to come up with this command:
gcc -v --help 2> /dev/null | sed -n '/^ *-std=\([^<][^ ]\+\).*/ {s//\1/p}'
It processes the output of g++ -v --help (silencing the extra info it prints to stderr), matches lines that start with -std= then captures the values. The ^< is to block the -std=<standard> line of the help. Here is some example output for GCC 9:
f2003
f2008
f2008ts
f2018
f95
gnu
legacy
c++03
c++0x
c++11
c++14
c++17
c++1y
c++1z
c++2a
c++98
c11
c17
c18
c1x
c2x
c89
c90
c99
c9x
gnu++03
gnu++0x
gnu++11
gnu++14
gnu++17
gnu++1y
gnu++1z
gnu++2a
gnu++98
gnu11
gnu17
gnu18
gnu1x
gnu2x
gnu89
gnu90
gnu99
gnu9x
iso9899:1990
iso9899:199409
iso9899:1999
iso9899:199x
iso9899:2011
iso9899:2017
iso9899:2018
You can add a grep in the middle to filter based on help description text, which is conveniently consistent in the help output. E.g. if you want to drop the deprecated ones:
gcc -v --help 2> /dev/null | grep -iv deprecated | sed -n '/^ *-std=\([^<][^ ]\+\).*/ {s//\1/p}'
If you want to list just non-deprecated C++:
gcc -v --help 2> /dev/null | grep -iv deprecated | grep "C++" | sed -n '/^ *-std=\([^<][^ ]\+\).*/ {s//\1/p}'
If you want to list just non-deprecated C:
gcc -v --help 2> /dev/null | grep -iv deprecated | grep "C " | sed -n '/^ *-std=\([^<][^ ]\+\).*/ {s//\1/p}'
Those are pretty hacky and rely on "deprecated", "C++" and/or "C" (note the space at the end of grep "C "!) appearing in the help description for each standard name but they seem to work.
You could similarly filter out e.g. "same as" to get rid of synonymous ones, etc.