@@ -74,21 +74,12 @@ class BackendOptions {
7474 */
7575 BackendOptions () : size_(0 ) {}
7676
77- /* *
78- * Returns a const view of all stored options as a Span.
79- *
80- * @return A const Span containing all BackendOption entries
81- */
82- executorch::runtime::Span<const BackendOption> view () const {
83- return executorch::runtime::Span<const BackendOption>(options_, size_);
84- }
85-
8677 /* *
8778 * Returns a mutable view of all stored options as a Span.
8879 *
8980 * @return A mutable Span containing all BackendOption entries
9081 */
91- executorch::runtime::Span<BackendOption> mutable_view () {
82+ executorch::runtime::Span<BackendOption> view () {
9283 return executorch::runtime::Span<BackendOption>(options_, size_);
9384 }
9485
@@ -101,9 +92,13 @@ class BackendOptions {
10192 * @param value The boolean value to set
10293 * @return Error::Ok on success, Error::InvalidArgument if storage is full
10394 */
104- template <size_t N>
105- Error set_option (const char (&key)[N], bool value) noexcept {
106- static_assert (N <= kMaxOptionKeyLength , " Option key is too long" );
95+ Error set_option (const char * key, bool value) noexcept {
96+ ET_CHECK_MSG (
97+ strlen (key) <= kMaxOptionKeyLength ,
98+ " Option key %s (%zu) is too long (max %zu)" ,
99+ key,
100+ strlen (key),
101+ kMaxOptionKeyLength );
107102 return set_option_impl (key, value);
108103 }
109104
@@ -116,9 +111,13 @@ class BackendOptions {
116111 * @param value The integer value to set
117112 * @return Error::Ok on success, Error::InvalidArgument if storage is full
118113 */
119- template <size_t N>
120- Error set_option (const char (&key)[N], int value) noexcept {
121- static_assert (N <= kMaxOptionKeyLength , " Option key is too long" );
114+ Error set_option (const char * key, int value) noexcept {
115+ ET_CHECK_MSG (
116+ strlen (key) <= kMaxOptionKeyLength ,
117+ " Option key %s (%zu) is too long (max %zu)" ,
118+ key,
119+ strlen (key),
120+ kMaxOptionKeyLength );
122121 return set_option_impl (key, value);
123122 }
124123
@@ -134,9 +133,13 @@ class BackendOptions {
134133 * @param value The string value to set (must have static storage duration)
135134 * @return Error::Ok on success, Error::InvalidArgument if storage is full
136135 */
137- template <size_t N>
138- Error set_option (const char (&key)[N], const char* value) noexcept {
139- static_assert (N <= kMaxOptionKeyLength , " Option key is too long" );
136+ Error set_option (const char * key, const char * value) noexcept {
137+ ET_CHECK_MSG (
138+ strlen (key) <= kMaxOptionKeyLength ,
139+ " Option key %s (%zu) is too long (max %zu)" ,
140+ key,
141+ strlen (key),
142+ kMaxOptionKeyLength );
140143 // Create a fixed-size array and copy the string
141144 std::array<char , kMaxOptionValueLength > arr;
142145 strncpy (arr.data (), value, kMaxOptionValueLength - 1 );
0 commit comments