any_cast must not trigger the instantiation of the manager function for types which don't meet the requirements for being stored in an any object. PR libstdc++/69321 * include/experimental/any (__any_caster): Avoid instantiating manager function for types that can't be stored in any. * include/std/any (__any_caster): Likewise. * testsuite/20_util/any/misc/any_cast.cc: Test non-copyable type. * testsuite/experimental/any/misc/any_cast.cc: Likewise. Tested powerpc64le-linux, committed to trunk.