View | Details | Raw Unified | Return to problem 2463 | Differences between
and this patch

Collapse All | Expand All

(-)a/source/global/management/include/G4String.hh (+15 lines)
Lines 96-101 class G4String : public std::string Link Here
96
  ///   to match the `std::string` interface.
96
  ///   to match the `std::string` interface.
97
  inline operator const char*() const;
97
  inline operator const char*() const;
98
98
99
  /// @brief Override of subscript operator for `int` to suppress C2666 errors with MSVC
100
  /// @deprecated Will be removed at the same time as `operator const char*` that requires it
101
  ///
102
  /// This override is required because of G4String's provision of an implicit conversion
103
  /// operator to `const char*`. Together with the subscript operator and C++'s built-in
104
  /// `operator[](const char*, int) operator, use of G4String::operator[] will trigger
105
  /// [MSVC error C2666](https://docs.microsoft.com/en-us/cpp/error-messages/compiler-errors-2/compiler-error-c2666?view=msvc-170)
106
  /// This is a known issue with mixing implicit conversion to `const char*` and subscript
107
  /// operators. Provision of the override with `int` argument is thus a workaround
108
  /// until the conversion operator is removed.
109
  inline reference operator[](int);
110
111
  /// @overload  
112
  inline const_reference operator[](int) const;
113
99
  /// @brief Deprecated function
114
  /// @brief Deprecated function
100
  /// @deprecated Use `std::string::compare` or `G4StrUtil::icompare` instead
115
  /// @deprecated Use `std::string::compare` or `G4StrUtil::icompare` instead
101
  [[deprecated("Use std::string::compare, or G4StrUtil::icompare for case-insensitive comparison")]]
116
  [[deprecated("Use std::string::compare, or G4StrUtil::icompare for case-insensitive comparison")]]
(-)a/source/global/management/include/G4String.icc (+10 lines)
Lines 62-67 inline G4String& G4String::operator=(G4String&& str) Link Here
62
62
63
inline G4String::operator const char*() const { return c_str(); }
63
inline G4String::operator const char*() const { return c_str(); }
64
64
65
inline G4String::reference G4String::operator[](int pos)
66
{
67
  return std::string::operator[](pos);
68
}
69
70
inline G4String::const_reference G4String::operator[](int pos) const
71
{
72
    return std::string::operator[](pos);
73
}
74
65
inline G4int G4String::compareTo(std::string_view str, caseCompare mode) const
75
inline G4int G4String::compareTo(std::string_view str, caseCompare mode) const
66
{
76
{
67
  if(mode == exact)
77
  if(mode == exact)

Return to problem 2463