standards

Bit manipulations good practices

独自空忆成欢 提交于 2019-12-03 08:12:11
问题 As a beginner C programmer, I am wondering, what would be the best easy-to-read and easy-to-understand solution for setting control bits in a device. Are there any standards ? Any example code to mimic? Google didn't give any reliable answer. For example, I have a control block map: The first way I see would be to simply set the needed bits. It requires a bunch of explanations in comments and seems to be not all that professional. DMA_base_ptr[DMA_CONTROL_OFFS] = 0b10001100; The second way I

Standards for Date/Time addition?

不想你离开。 提交于 2019-12-03 07:16:56
问题 I'm looking for standards for Date/Time addition. I haven't been able to find any. In particular I'm hoping to find a spec that defines what should happen when you add a month to a date like January 31st. Is the right answer February 28th(/29th)? March 1st? March 2nd? I've seen inconsistent implementations between different tools (PHP & MySQL in this case), and I'm trying to find some sort of standards to base my work on. Differing Results: PHP $end = strtotime("+1 month", 1314835200); /

hiding of template parameter of member template

╄→尐↘猪︶ㄣ 提交于 2019-12-03 06:41:56
from temp.local : In the definition of a member of a class template that appears outside of the class template definition, the name of a member of the class template hides the name of a template-parameter of any enclosing class templates ( but not a template-parameter of the member if the member is a class or function template ). [ Example: template<class T> struct A { struct B { /* ... */ }; typedef void C; void f(); template<class U> void g(U); }; template<class B> void A<B>::f() { B b; // A's B, not the template parameter } template<class B> template<class C> void A<B>::g(C) { B b; // A's B

Why do primitive and user-defined types act differently when returned as 'const' from a function?

爱⌒轻易说出口 提交于 2019-12-03 06:29:03
问题 #include <iostream> using namespace std; template<typename T> void f(T&&) { cout << "f(T&&)" << endl; } template<typename T> void f(const T&&) { cout << "f(const T&&)" << endl; } struct A {}; const A g1() { return {}; } const int g2() { return {}; } int main() { f(g1()); // outputs "f(const T&&)" as expected. f(g2()); // outputs "f(T&&)" not as expected. } The issue description is embedded in the code. My compiler is clang 5.0 . I just wonder: Why does C++ treat built-in types and custom

Why does no database fully support ANSI or ISO SQL standards?

别来无恙 提交于 2019-12-03 06:28:33
问题 If I were designing a oil refinery, I wouldn't expect that materials from different vendors would not comply with published standards in subtle yet important ways. Pipework, valves and other components from one supplier would come with flanges and wall thicknesses to ANSI standards, as would the same parts from any other supplier. Interoperability and system safety is therefore assured. Why then are the common databases so choosy about which parts of the standards they adhere to, and why have

Paypal Payment Standard: Callback URL

坚强是说给别人听的谎言 提交于 2019-12-03 05:56:47
On Paypal Sandbox: After logging in using a test account and then clicking the "Pay Now" button, the user is redirected to "Thanks for your order" page inside Paypal. The page has three(3) links below the message that says: Return to Test Store Go to PayPal account overview Add funds from your bank Clicking the "Return to Test Store" will redirect me to the return URL I specified on my query string. This marks the order as "Completed" or whatever the value of the payment_status returned by Paypal is. The Problem : Clicking the other links bypasses the return URL and goes to user account

C++ function returning function

流过昼夜 提交于 2019-12-03 05:40:09
问题 Where in the standard are functions returning functions disallowed? I understand they are conceptually ridiculous, but it seems to me that the grammar would allow them. According to this webpage, a "noptr-declarator [is] any valid declarator" which would include the declarator of a function: int f()(); Regarding the syntax. It seems to me that the syntax, as spelled out in [dcl.decl], allows int f(char)(double) which could be interpreted as the function f that takes a char and returns a

What does mean for a name or type to have a certain language linkage?

≯℡__Kan透↙ 提交于 2019-12-03 05:31:35
问题 According to (c) ANSI ISO/IEC 14882:2003, page 127: Linkage specifications nest. When linkage specifications nest, the innermost one determines the language. A linkage specification does not establish a scope. A linkage-specification shall occur only in namespace scope (3.3). In a linkage-specification, the specified language linkage applies to the function types of all function declarators, function names, and variable names introduced by the declaration(s). extern "C" void f1(void(*pf)(int)

Mystical restriction on std::binary_search

こ雲淡風輕ζ 提交于 2019-12-03 05:23:35
Problem description: Consider some structure having an std::string name member. For clearness let's suppose that it's a struct Human , representing information about people. Besides the name it can also have many other data members. Let there be a container std::vector<Human> vec , where the objects are already sorted by name . Also for clearness suppose that all the names are unique. The problem is : having some string nameToFind find out if there exists an element in the array having such name. Solution and my progress: The obvious and natural solution seems to perform a binary search using

Can you use multiple .JS files when developing a complex Javascript application?

早过忘川 提交于 2019-12-03 04:48:17
问题 Coming from a C# background where every class is (best practices) stored in its own individual file, it makes development quite clean. I've never written anything complex in Javascript in the past, but I am starting to learn HTML 5 and I want to write a complex game using the HTML 5 canvas. Putting all of my functions and code into a single .js file seems very messy. Is there a way to split it up, or a tool/IDE that lets you develop using separate files and compile them into a single one for