Storing C++ template function definitions in a .CPP file

I have some template code that I would prefer to have stored in a CPP file instead of inline in the header. I know this can be done as long as you know which template types will be used. For...

Using G++ to compile multiple .cpp and .h files

I've just inherited some C++ code that was written poorly with one cpp file which contained the main and a bunch of other functions. There are also .h files that contain classes and their function...

Why use #ifndef CLASS_H and #define CLASS_H in .h file but not in .cpp?

I have always seen people write class.h #ifndef CLASS_H #define CLASS_H //blah blah blah #endif The question is, why don't they also do that for the .cpp file that contain definitions for...

How to provide $ to third-party, external jQuery plugins in Django admin

I've included a couple of third-party jQuery plugins in my Django admin base template which assume "$" to be available. For my own code, I've always been happy to just do (function($) { ...

using extern template (C++11)

Figure 1: function templates TemplHeader.h template<typename T> void f(); TemplCpp.cpp template<typename T> void f(){ //... } //explicit instantation template void...

C++11: How to alias a function?

If I have a class Foo in namespace bar: namespace bar { class Foo { ... } }; I can then: using Baz = bar::Foo; and now it is just like I defined the class in my namespace with the name...

Stop an R program without error

Is there any way to stop an R program without error? For example I have a big source, defining several functions and after it there are some calls to the functions. It happens that I edit some...

Sublime Text shortcut for stepping into a function

In Eclipse, one can use ctrl + click to go directly to a function definition. For example: f = my_tool.main() If I ctrl + click on main(), then I will be directed to the code for the main...

"Private" attribute properties in Python

I'm relatively new to Python so I hope I haven't missed something, but here goes... I'm trying to write a Python module, and I'd like to create a class with a "private" attribute that can (or...

Expand a macro in a macro

Given the following macros giving access to compiler attributes in a function-call way, like spec(section(".mysection")) void foo(void);: #define spec(_H_) spec_##_H_ #define spec_section(_S_)...

Error updating EDMX file

I've seen some other posts about this, but none of the answers seem to help. I'm trying to add a stored procedure to an EDMX. I open the diagram, right-mouse-click, and choose "Update Model from...

Is a conditional function definition allowed in POSIX compliant shell scripts?

In Bash and KornShell (ksh), I see the following script works fine. if [ -n "foo" ] then foo() { echo function foo is defined } else bar() { echo function bar...

TypeScript Cannot find namespace despite Variable being in same Class

I'm trying to define Callbackdefinitions to make it easier to work with many callbacks in my Node.js project. My database.ts file looks like that: export default class Database { //Export the...

Go to definition and back to reference in visual Studio Code

I'm currently using VSCode and am trying to use the F12 shortcut which takes me to a definition of an object/function. When I want to go back to the reference, I can't seem to find the right way...

Passing null string to function as an argument

What is the right way of passing NULL string to a function without creating a variable? I see compilation error with following code and I don't want to change the definition. Also may have to...

Typescript interface, function and namespace all have the same name. Which is being exported?

In the Typescript definition file (DefinitelyTyped) I am examining, there is an interface, a function and a namespace all with the exact same name: twilio. Here is the sample, from the first few...

Using JSON Web Tokens (JWT) with Azure Functions (WITHOUT using Active Directory)

I am sure someone out there has already done this, but I have yet to find any documentation with regard to the Microsoft implementation of JWT. The official documentation from Microsoft for their...

Convert an integer array to json in c

I have a buffer which is filled by an external hardware (DMA). When this happens, I can print the data using the following code: void* buffer; ... /*buffer is initialized and filled at some...

Typescript generic parameters that extends exclusive unions

In TypeScript, is there a way to define a generic parameter that extends only one value of a union type? For example, assuming I declare a union type as follows: type Any = "A" | "B" then if I...

Using Neural Networks in optimization problems

I am trying to use Keras in order to set up a neural network, which is supposed to approximate an unknown function F(x). The resulting neural-network approximation for F(x) should then be used in...

How Should VSCode Be Configured To Support A Lerna Monorepo?

I have a lerna monorepo containing lots of packages. I'm trying to achieve the following: Ensure that VSCode provides the correct import suggestions (based on package names, not on relative...

How do I write a recursive function to print a string in reverse in C?

I need any given string to be printed in reverse using recursion. I have tried changing the function prototype and definition by changing the return value type and parameter list of the function...

Why is it necessary to add a bias to the dividend for signed division by a power of 2?

I'm learning about assembly code in "Computer Systems- A Programmer's Perspective", and I encountered the following example: In the following C function, we have left the definition of...

How to pass input parameter to AWS Glue Map.apply function

I am working on an AWS Glue job where I have a function "some_function" that I want to apply on DynamicFrame dy_f, but I also want to pass an input param to...

How to type pipe function using variadic tuple types in TypeScript 4?

The example of the release notes of TypeScript 4 shows how to use variadic tuple types to avoid several overload definitions. I guess it should be possible to type this pipe function for an...

Exception handling based on library

Library This exception handling scenario deals with the exceptional cases that arise in a typical library interface of a Town library. About the Library Interface This is a typical interface...

Can `consteval` delegating constructor be called from an ordinary constructor?

In the following struct definition, the constructor A(int) delegates its work to immediate-function constructor A(): struct A { int i = 0; consteval A() = default; A(int) : A()...

Non-literal types and constant expressions

struct A { ~A() {} consteval A() {} consteval auto f() {} }; int main() { A{}; //A{}.f(); //1 } https://godbolt.org/z/4KPY5P7o7 This program is accepted by ICC, GCC...

Monadic compose with discarding (>>) flipped

The definition of (>>) function is following: (>>) :: Monad m => m a -> m b -> m b But I would like to achieve this function flipped like following: I have a function tabulate :: Int -> [Int] ->...

Why does hint::spin_loop use ISB on aarch64?

In std::hint there's a spin_loop function with the following definition in its documentation: Emits a machine instruction to signal the processor that it is running in a busy-wait spin-loop...