Unexpected indentation behavior on C++

What happened?

Hello,

I am using Doom Emacs as my primary code editor and I have c++ with lsp using ccls (however, lsp doesn’t seem to be the problem here).

I detected some confusing behavior when indenting a .hpp file. I have the following in config.el:

(setq-default c-basic-offset 4
              tab-width 4
              indent-tabs-mode t)

But for a simple code like:

#include <functional>
#include <iostream>

#ifndef RAND_LF_H_
#define RAND_LF_H_

class particle{
    public:
        double R;
        double x,y;
        double vx,vy;
        std::function<double(double x)>Fx;
};

#endif // RAND_LF_H_

I get the next warnings:

Note: c-basic-offset, tab-width adjusted to 8 Note: indent-tabs-mode adjusted to nil

And effectively the indentation space is 8 and not 4 anymore. I have traced the error to the line with std::function . When I delete it, the indentation is normal. However, I have no idea why this is the case. If anyone can explain this to me and how to avoid it I would be very grateful since this is really annoying. Thank you!

System information


Loading data dump...