qualifiers

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

谁说胖子不能爱 提交于 2019-12-10 12:49:11
问题 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 functions void startMoving() and sf::Vector2f getPosition() const . Now, I can without problems call entityManager_.getPlayer().startMoving(); from within my Game class, but when I try for example the following code to get the player's position: sf:

C++0x | Why std::atomic overloads each method with the volatile-qualifier?

不问归期 提交于 2019-12-08 19:28:55
问题 The following excerpt from the current draft shows what I mean: namespace std { typedef struct atomic_bool { bool is_lock_free() const volatile; bool is_lock_free() const; void store(bool, memory_order = memory_order_seq_cst) volatile; void store(bool, memory_order = memory_order_seq_cst); bool load(memory_order = memory_order_seq_cst) const volatile; bool load(memory_order = memory_order_seq_cst) const; operator bool() const volatile; operator bool() const; bool exchange(bool, memory_order =

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

删除回忆录丶 提交于 2019-12-08 15:07:29
问题 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 that could be detected, why would I need to type const anywhere? I know that the inline keyword has become obsolete because of compiler advances. Isn't it time that const do the same? 回答1: Yes, the compiler can prove constness in your example. No, it would be

Android resource size qualifier

 ̄綄美尐妖づ 提交于 2019-12-08 06:35:27
问题 I unable to get the values from "values-sw480dp" nor on my sony Xperia device which is 480 x 854 neither on Samsung galaxy tab which is 600 x 1024. But able to get on Motorola Xoom which is 1280 x 752. e.g res/values-sw480dp/strings.xml/ <string name="hello_world">hello world</string> The values on respective devices Sony Xperia ----> @2131034113 Samsung ----> @2131034113 on xoom ---> hello world Can any one explain me this behavior, why Sony Xperia and Samsung has "@2131034113" value. Thank

Kotlin + Dagger2: cannot be provided without an @Inject constructor or from an @Provides- or @Produces-annotated method

自作多情 提交于 2019-12-07 00:33:24
问题 I'm getting the following error: Error:(8, 1) error: java.lang.String cannot be provided without an @Inject constructor or from an @Provides- or @Produces-annotated method. I'm stuck trying to make a module that provides two qualified Strings. Here is the simplified setup of dagger. @Singleton @Component(modules = [GreetingsModule::class]) interface AppComponent { fun inject(activity: MainActivity) } @Qualifier annotation class Spanish @Qualifier annotation class French @Qualifier annotation

Kotlin + Dagger2: cannot be provided without an @Inject constructor or from an @Provides- or @Produces-annotated method

亡梦爱人 提交于 2019-12-05 04:39:38
I'm getting the following error: Error:(8, 1) error: java.lang.String cannot be provided without an @Inject constructor or from an @Provides- or @Produces-annotated method. I'm stuck trying to make a module that provides two qualified Strings. Here is the simplified setup of dagger. @Singleton @Component(modules = [GreetingsModule::class]) interface AppComponent { fun inject(activity: MainActivity) } @Qualifier annotation class Spanish @Qualifier annotation class French @Qualifier annotation class English @Module @Singleton class GreetingsModule { @Provides @Spanish fun providesHola(): String

What is “the issue” with variable qualifier placement?

你。 提交于 2019-12-04 08:53:49
In this document , under the section labeled "Variable Qualifiers", Apple says: You should decorate variables correctly. When using qualifiers in an object variable declaration, the correct format is: ClassName * qualifier variableName; for example: MyClass * __weak myWeakReference; MyClass * __unsafe_unretained myUnsafeReference; Other variants are technically incorrect but are “forgiven” by the compiler. To understand the issue, see http://cdecl.org/ . Looking at cdecl.org doesn't clarify anything. Can anyone explain what "the issue" they are referring to is? In other words, help me convince

const-ness as template argument

旧巷老猫 提交于 2019-12-03 06:42:14
I have two structs: // ----- non-const ----- struct arg_adapter { EArgType type; // fmtA, fmtB, ... union { TypeA * valueA; TypeB * valueB; // ... more types } arg_adapter(TypeA & value) : type(fmtA), valueA(&value) {} arg_adapter(TypeB & value) : type(fmtB), valueB(&value) {} // ... } // ----- const version ----- struct const_arg_adapter { EArgType type; // fmtA, fmtB, ... union { TypeA const * valueA; TypeB const * valueB; // ... more types } arg_adapter(TypeA const & value) : type(fmtA), valueA(&value) {} arg_adapter(TypeB const & value) : type(fmtB), valueB(&value) {} // ... } They are

When defining a member function out-of-line, which qualifiers must appear in the declaration / definition / both?

瘦欲@ 提交于 2019-12-01 20:19:12
I am almost sure this has been asked before. Unfortunately, my C++ has become so rusty that I don't even know what to search for. Is there an easy-to-remember rule of thumb that would tell me which qualifiers ( inline , virtual , override , const , mutable , etc.) must appear (a) only in the declaration, (b) only in the definition, (c) both in the declaration and definition when I define a member function out-of-line? Example: struct Geometry { … virtual Geometry* clone() const = 0; }; struct Point2 : public Geometry { … virtual Point2* clone() const override { … } }; If I wanted to define

C++98/03 reference collapsing and cv qualifiers

此生再无相见时 提交于 2019-12-01 17:00:40
问题 The code below compiles (gcc 4.7.2 or icc 13) and produces "1 2" output. Which means that const qualifier is dropped, i. e., f<int&> has the parameter type int& . Why does it happen? As I understand, according to §14.3.1.4: If a template-argument for a template-parameter T names a type “reference to cv1 S ”, an attempt to create the type “reference to cv2 T ” creates the type “reference to cv12 S ”, where cv12 is the union of the cv-qualifiers cv1 and cv2 . Redundant cv-qualifiers are ignored.