Questions tagged [qualifiers]

A qualifier adds an extra "quality", such as specifying volatility or constness of a variable

They're similar to adjectives: "a fickle man", "a volatile int", "an incorruptible lady", "a const double". With or without a qualifier, the variable itself still occupies the same amount of memory, and each bit has the same interpretation or contribution to the state/value. Qualifiers just specify something about how it may be accessed or where it is stored

Credits goes to Tony_D @ What is the meaning of "qualifier"?

211 questions
267
votes
3 answers

What is "rvalue reference for *this"?

Came across a proposal called "rvalue reference for *this" in clang's C++11 status page. I've read quite a bit about rvalue references and understood them, but I don't think I know about this. I also couldn't find much resources on the web using the…
ryaner
  • 3,927
  • 4
  • 20
  • 23
66
votes
3 answers

Double pointer const-correctness warnings in C

A pointer to non-const data can be implicitly converted to a pointer to const data of the same type: int *x = NULL; int const *y = x; Adding additional const qualifiers to match the additional indirection should logically work the same…
31
votes
4 answers

What's a use case for overloading member functions on reference qualifiers?

C++11 makes it possible to overload member functions based on reference qualifiers: class Foo { public: void f() &; // for when *this is an lvalue void f() &&; // for when *this is an rvalue }; Foo obj; obj.f(); // calls lvalue…
KnowItAllWannabe
  • 12,972
  • 8
  • 50
  • 91
22
votes
4 answers

What is the meaning of void* volatile* in c++

I am looking at the following code: inline void* interlocked_read_acquire(void* volatile* x); and am wondering why not just a volatile void* as an argument. In general what is the semantics or definition of a volatile*? I am also making the…
Matthew Hoggan
  • 7,402
  • 16
  • 75
  • 140
20
votes
1 answer

Is there a way to build C++ custom qualifiers?

Is there any way to implement a custom type qualifier (similar to const)? I would like to only allow function calls to functions that are of the right qualification, within functions with the same qualification. Let's say I would have: void…
Andreas Loanjoe
  • 2,205
  • 10
  • 26
19
votes
2 answers

std::remove_reference or std::remove_cv first?

If I want to extract the type of a const reference (like double from const double&), do I have to use : typename std::remove_cv::type>::type or typename std::remove_reference
Vincent
  • 57,703
  • 61
  • 205
  • 388
17
votes
2 answers

What Does cv-qualified Mean?

I have started seeing the term "cv-qualified" being thrown around a lot. An answer to my last question: if T is a (possibly cv-qualified) class type (Clause 9), the default constructor (12.1) for T is called Can someone define that for me?
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
15
votes
3 answers

const-ness as template argument

I have two structs: // ----- non-const ----- struct arg_adapter { EArgType type; // fmtA, fmtB, ... union { TypeA * valueA; TypeB * valueB; // ... more types } arg_adapter(TypeA & value)…
peterchen
  • 40,917
  • 20
  • 104
  • 186
14
votes
1 answer

Object has type qualifiers that are not compatible with the member function

My class Game has a member EntityManager entityManager_. The class EntityManager has a private member Player player_ and the public getter function Player &EntityManager::getPlayer() which returns player_. The class Player has for example the…
A. D.
  • 728
  • 1
  • 9
  • 27
13
votes
1 answer

C++11: Abstracting over const, volatile, lvalue reference, and rvalue reference qualified member function pointers?

C++03 lets you qualify function parameters as being const, volatile, and/or lvalue references (&). C++11 adds one more: rvalue references (&&). Furthermore, C++ lets you overload functions based on the qualifiers of their parameters, so that the…
glaebhoerl
  • 7,695
  • 3
  • 30
  • 41
13
votes
5 answers

Should ALL global variables be volatile-qualified?

In this example, does correctness require global_value to be declared volatile? int global_value = 0; void foo () { ++ global_value; } void bar () { some_function (++global_value); foo (); some_function (++global_value); } My…
spraff
  • 32,570
  • 22
  • 121
  • 229
13
votes
3 answers

How to read Qualifier from property file in spring boot?

I have a Qualifier where I read from public class TestController{ @Autowired @Qualifier("jdbc") private JdbcTemplate jtm; //..... } The qualifier "jdbc" is the bean defined as @Bean(name = "jdbc") @Autowired public…
Ricky
  • 2,662
  • 5
  • 25
  • 57
12
votes
8 answers

Can the compiler not determine whether a variable is const by Itself?

I know for a function this simple it will be inlined: int foo(int a, int b){ return a + b; } But my question is, can't the compiler just auto-detect that this is the same as: int foo(const int a, const int b){ return a + b; } And since…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
9
votes
2 answers

Can maven handle custom qualifiers?

I'm trying to figure out if what Maven's policy is on custom qualifiers. I know that there exists specific qualifiers in Version strings that maven checks for, such as: 1.0.0-SNAPSHOT 5.3.0-beta-5 etc, but I was wondering if I could write specific…
DrakeAnderson
  • 492
  • 4
  • 12
9
votes
1 answer

Are type qualifiers part of the type of an expression?

In C, are type qualifiers such as const , volatile, restrict , and _Atomic part of the type of an expression? For example const int x = 3; Which is the type of x, const int or int? Does the type of a function include type qualfiers of…
user3284469
1
2 3
14 15