CPP's problem on the assignment of compare functions in multiset

1. When I created a member type of multiset for the class Basket, there was a problem specifying that the compare was constructed using multiset
.

2. The program code is as follows:

class Basket
{
private:
    static bool comp(const std::shared_ptr<Quote> &lhs,
                        const std::shared_ptr<Quote> &rhs);
    std::multiset<std::shared_ptr<Quote>, decltype(comp) *>
                _items{comp};

    /*
    error:  "comp"  is not a type
                 _items(comp);

    std::multiset<std::shared_ptr<Quote>, decltype(comp) *>
                _items(comp);
    */
}

3. Compile instruction:

gPP -s -std=cPP11 -w -Wall -Werror quote.cc -o quote.so

4. Error message:

calling the constructor of multiset with () will make an error, but it will be correct with {}. What is the reason for this?

quote.h:226:24: error:  "comp"  is not a type
                 _items(comp);
CPP
Apr.28,2022

there are only two legal ways to initialize data members through default member initializer . The first is list initialization, a pair of curly braces. The second is copy initialization, or equal sign.

if you try to use parentheses, the compiler will treat this line declaration as a function declaration. So the syntax error of "comp is not a type" is reported.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3e2df-2c41e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3e2df-2c41e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?