This is an automated email from the ASF dual-hosted git repository.

bneradt pushed a commit to branch textview-constructors
in repository https://gitbox.apache.org/repos/asf/trafficserver-libswoc.git

commit 7a3dfc5076d3ff595bfd48f98bd91514004da4a0
Author: Alan M. Carroll <[email protected]>
AuthorDate: Wed Feb 10 13:10:36 2021 -0600

    First pass on better TextView constructors.
---
 code/include/swoc/TextView.h | 12 ++++++------
 unit_tests/test_TextView.cc  |  6 ++++--
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/code/include/swoc/TextView.h b/code/include/swoc/TextView.h
index 5823903..fcea0a3 100644
--- a/code/include/swoc/TextView.h
+++ b/code/include/swoc/TextView.h
@@ -148,23 +148,23 @@ public:
       @endcode
       The last character in @a a will be 'g'.
    */
-  template <size_t N> constexpr TextView(const char (&s)[N]) noexcept;
+  template <size_t N> constexpr TextView(char const (&s)[N]) noexcept;
 
   /** Construct from a C-string.
    *
    * @param src A pointer to a C-string.
    *
-   * @internal This is a reference because it is other ambiguous with the 
array constructor.
+   * @internal This is a reference because it is otherwise ambiguous with the 
array constructor.
    */
-  TextView(char *& src) : super_type(src) {}
+  TextView(char * & src) : super_type(src) {}
 
   /** Construct from a const C-string.
    *
    * @param src Pointer to a const C-string.
    *
-   * @internal This is a reference because it is other ambiguous with the 
array constructor.
+   * @internal This is a reference because it is otherwise ambiguous with the 
array constructor.
    */
-  TextView(char const*& src) : super_type(src) {}
+  TextView(char const * & src) : super_type(src) {}
 
   /** Construct from nullptr.
       This implicitly makes the length 0.
@@ -971,7 +971,7 @@ inline constexpr TextView::TextView(char const *first, char 
const *last) noexcep
 inline constexpr TextView::TextView(std::nullptr_t) noexcept : 
super_type(nullptr, 0) {}
 inline TextView::TextView(std::string const &str) noexcept : super_type(str) {}
 inline constexpr TextView::TextView(super_type const &that) noexcept : 
super_type(that) {}
-template <size_t N> constexpr TextView::TextView(const char (&s)[N]) noexcept 
: super_type(s, s[N - 1] ? N : N - 1) {}
+template <size_t N> constexpr TextView::TextView(char const (&s)[N]) noexcept 
: super_type(s, s[N - 1] ? N : N - 1) {}
 
 inline void
 TextView::init_delimiter_set(std::string_view const &delimiters, 
std::bitset<256> &set) {
diff --git a/unit_tests/test_TextView.cc b/unit_tests/test_TextView.cc
index dd8f2cc..cf06c45 100644
--- a/unit_tests/test_TextView.cc
+++ b/unit_tests/test_TextView.cc
@@ -43,8 +43,7 @@ TEST_CASE("TextView Constructor", "[libswoc][TextView]")
   TextView f(base.data(), 15);
   TextView u{base.data(), ux};
 
-  // Check the various forms of char pointers work unamibiguously.
-  TextView bob{"Bob"};
+  // Check the various forms of char pointers work unambiguously.
   char q[12] = "Bob";
   TextView t_q{q};
   REQUIRE(t_q.data() == q);
@@ -54,6 +53,9 @@ TEST_CASE("TextView Constructor", "[libswoc][TextView]")
   char const *qcp = "Bob";
   TextView t_qcp{qcp};
   REQUIRE(t_qcp.data() == qcp);
+//  char const * const qcpc = "Bob";
+//  TextView t_qcpc{qcpc};
+//  REQUIRE(t_qcpc.data() == qcp);
 };
 
 TEST_CASE("TextView Operations", "[libswoc][TextView]")

Reply via email to