jeudi 20 juillet 2023

A question about type traits std::remove_cv

My reference is to the example provided hereunder:

std::remove_cv, std::remove_const, std::remove_volatile

In the example,

using type4 = std::remove_cv<const volatile int*>::type;
using type5 = std::remove_cv<int* const volatile>::type;

std::cout << std::is_same<type4, int*>::value << ' '
              << std::is_same<type4, const volatile int*>::value << '\n';

    std::cout << std::is_same<type5, int*>::value << '\n';

Output

false true

true

I am assuming that there is a typo in the output as it doesn't match the test in the example, if my understanding of the concept is correct. The output instead should have been

true false

true

Can someone confirm or correct this?

TIA

Aucun commentaire:

Enregistrer un commentaire