vcl/source/font/font.cxx |   19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

New commits:
commit ccb101abd46e1d632d18b30226a6bffed7a66381
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Mon Mar 1 10:17:47 2021 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Mon Mar 1 12:27:38 2021 +0100

    call to consteval function is not a constant expression (HAVE_CPP_CONSTEVAL)
    
    ...when building with suitable --with-latest-c++ since
    16901e4ccad95d55d4ae0fa2d6f6103b4177592e "Simplify static string 
generation",
    
    > vcl/source/font/font.cxx:396:20: error: call to consteval function 
'rtl::OUStringLiteral<96>::OUStringLiteral' is not a constant expression
    >             return OUStringLiteral(aArray);
    >                    ^
    > include/rtl/ustring.hxx:95:16: note: read of non-constexpr variable 
'aArray' is not allowed in a constant expression
    >         assert(literal[N - 1] == '\0');
    >                ^
    > vcl/source/font/font.cxx:396:20: note: in call to 
'OUStringLiteral(aArray)'
    >             return OUStringLiteral(aArray);
    >                    ^
    > vcl/source/font/font.cxx:393:25: note: declared here
    >             sal_Unicode aArray[127 - 32 + 1];
    >                         ^
    
    So just keep it easy and spell out the contents explicitly, at least for 
now.
    
    Change-Id: Ic7d22e7fec3f909e219b428e9b6cf6045a08cb44
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111734
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/vcl/source/font/font.cxx b/vcl/source/font/font.cxx
index bb9fe10285c4..3996eec947ef 100644
--- a/vcl/source/font/font.cxx
+++ b/vcl/source/font/font.cxx
@@ -389,12 +389,19 @@ tools::Long Font::GetOrCalculateAverageFontWidth() const
         // as close as possible (discussion see documentation in task),
         // so calculate it. For discussion of method used, see task
         // buffer measure string creation, will always use the same
-        static const OUStringLiteral aMeasureString = [] { // not constexpr 
yet because of std::iota
-            sal_Unicode aArray[127 - 32 + 1];
-            std::iota(aArray, aArray + SAL_N_ELEMENTS(aArray) - 1, 32);
-            aArray[SAL_N_ELEMENTS(aArray) - 1] = u'\0';
-            return OUStringLiteral(aArray);
-        }();
+        static constexpr OUStringLiteral aMeasureString
+            = u"\u0020\u0021\u0022\u0023\u0024\u0025\u0026\u0027"
+               "\u0028\u0029\u002A\u002B\u002C\u002D\u002E\u002F"
+               "\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037"
+               "\u0038\u0039\u003A\u003B\u003C\u003D\u003E\u003F"
+               "\u0040\u0041\u0042\u0043\u0044\u0045\u0046\u0047"
+               "\u0048\u0049\u004A\u004B\u004C\u004D\u004E\u004F"
+               "\u0050\u0051\u0052\u0053\u0054\u0055\u0056\u0057"
+               "\u0058\u0059\u005A\u005B\u005C\u005D\u005E\u005F"
+               "\u0060\u0061\u0062\u0063\u0064\u0065\u0066\u0067"
+               "\u0068\u0069\u006A\u006B\u006C\u006D\u006E\u006F"
+               "\u0070\u0071\u0072\u0073\u0074\u0075\u0076\u0077"
+               "\u0078\u0079\u007A\u007B\u007C\u007D\u007E";
 
         const double fAverageFontWidth(
             pTempVirtualDevice->GetTextWidth(aMeasureString) /
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to