Certain apps are able to automatically input SMS verification codes through Google's SMS Retriever API. If the app doesn't utilize the API, Android Messages is able to detect those codes and let users copy them right from the SMS notification. Now, it appears that Google is about to close the gap by having its own Autofill service pull SMS verification codes all by itself with the latest Google Play services update.
If you already have Autofill enabled in your system settings, you'll be able to find a new item in the Google settings list called "Verification code autofill," which features a simple toggle to let Google autofill verification codes that come from text messages. XDA-Developers picked up on the feature in an APK teardown for beta v18.7.13.
One of our readers wrote in about this change, saying that it came in with the Google Play services update to v19.2.75. We have that update on one of our devices, but do not have this setting. We expect this feature to roll out gradually.
An app developer told XDA that Google's API isn't the easiest method for making SMS code copypasta because the text message requires extra formatting which includes a hash based on the signature of the app that's sending the code — that can be very confusing clutter.