2525 * will fail (and the operator will be included in the binary anyway).
2626 */
2727
28- #include < c10/util/ string_view.h >
28+ #include < string_view>
2929#include < c10/core/DispatchKey.h>
3030#include < c10/macros/Macros.h>
3131
3636
3737namespace c10 ::impl {
3838
39- constexpr bool allowlist_contains (string_view allowlist, string_view item); // Forward Declare
39+ constexpr bool allowlist_contains (std:: string_view allowlist, std:: string_view item); // Forward Declare
4040
4141/* *
4242 * In selective build mode returns true/false depending on whether a build
@@ -102,14 +102,14 @@ constexpr bool is_build_feature_available(const char* name) {
102102
103103// returns true iff allowlist contains item
104104// allowlist_contains("a;bc;d", "bc") == true
105- constexpr bool allowlist_contains (string_view allowlist, string_view item) {
105+ constexpr bool allowlist_contains (std:: string_view allowlist, std:: string_view item) {
106106 // Choose a really big value for next so that if something goes wrong
107107 // this code will blow up in a hopefully detectable way.
108108 size_t next = std::numeric_limits<size_t >::max ();
109109 for (size_t cur = 0 ; cur <= allowlist.size (); cur = next) {
110110 next = allowlist.find (' ;' , cur);
111- if (next != string_view::npos) {
112- if (allowlist.substr (cur, next - cur). compare (item) == 0 ) {
111+ if (next != std:: string_view::npos) {
112+ if (allowlist.substr (cur, next - cur) == item ) {
113113 return true ;
114114 }
115115 next++;
@@ -125,12 +125,12 @@ constexpr bool allowlist_contains(string_view allowlist, string_view item) {
125125
126126// Returns true iff the given op name is on the allowlist
127127// and should be registered
128- constexpr bool op_allowlist_check (string_view op_name [[maybe_unused]]) {
129- assert (op_name.find (" ::" ) != string_view::npos);
128+ constexpr bool op_allowlist_check (std:: string_view op_name [[maybe_unused]]) {
129+ assert (op_name.find (" ::" ) != std:: string_view::npos);
130130 // Use assert() instead of throw() due to a gcc bug. See:
131131 // https://stackoverflow.com/questions/34280729/throw-in-constexpr-function
132132 // https://github.com/fmtlib/fmt/issues/682
133- assert (op_name.find (" ( " ) == string_view::npos);
133+ assert (op_name.find (' ( ' ) == std:: string_view::npos);
134134#if !defined(TORCH_OPERATOR_WHITELIST)
135135 // If the TORCH_OPERATOR_WHITELIST parameter is not defined,
136136 // all ops are to be registered
@@ -150,21 +150,20 @@ constexpr bool op_allowlist_check(string_view op_name [[maybe_unused]]) {
150150
151151// Returns true iff the given schema string is on the allowlist
152152// and should be registered
153- constexpr bool schema_allowlist_check (string_view schema) {
153+ constexpr bool schema_allowlist_check (std:: string_view schema) {
154154#if defined(TORCH_FORCE_SCHEMA_REGISTRATION)
155155 return true ;
156156#else
157- return op_allowlist_check (schema.substr (0 , schema.find (" ( " )));
157+ return op_allowlist_check (schema.substr (0 , schema.find (' ( ' )));
158158#endif
159159}
160160
161161// Returns true iff the given custom class name is on the allowlist
162162// and should be registered
163- constexpr bool custom_class_allowlist_check (string_view custom_class_name) {
163+ constexpr bool custom_class_allowlist_check (std:: string_view custom_class_name [[maybe_unused]] ) {
164164#if !defined(TORCH_CUSTOM_CLASS_ALLOWLIST)
165165 // If the TORCH_CUSTOM_CLASS_ALLOWLIST parameter is not defined,
166166 // all custom classes are to be registered
167- (void )custom_class_name;
168167 return true ;
169168#else
170169 return allowlist_contains (
@@ -175,8 +174,8 @@ constexpr bool custom_class_allowlist_check(string_view custom_class_name) {
175174
176175// schema_allowlist_check() implicitly depends on a macro, TORCH_OPERATOR_WHITELIST.
177176// Add this API to pass arbitrary allowlist.
178- constexpr bool op_allowlist_contains_name_in_schema (string_view allowlist, string_view schema) {
179- return allowlist_contains (allowlist, schema.substr (0 , schema.find (" ( " )));
177+ constexpr bool op_allowlist_contains_name_in_schema (std:: string_view allowlist, std:: string_view schema) {
178+ return allowlist_contains (allowlist, schema.substr (0 , schema.find (' ( ' )));
180179}
181180
182181// Returns true iff the given dispatch key is on the allowlist
0 commit comments