templates

C++ template “deferred instantiation”

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-07 12:44:18
问题 What is meant with "deferred instantiation" in C++ templates? 回答1: Deferred instantiation is when the template is not instantiated until the corresponding entity is used for the first time. For example, you have a templated function: template<int Size> void YourFunction() { //does something } parameter Size can have any possible value that int can have. Do you automatically have the templated function instantiated for all possible values of Size ? No, the template is only instantiated for the

C++ template “deferred instantiation”

空扰寡人 提交于 2021-02-07 12:43:36
问题 What is meant with "deferred instantiation" in C++ templates? 回答1: Deferred instantiation is when the template is not instantiated until the corresponding entity is used for the first time. For example, you have a templated function: template<int Size> void YourFunction() { //does something } parameter Size can have any possible value that int can have. Do you automatically have the templated function instantiated for all possible values of Size ? No, the template is only instantiated for the

Should decltype(foo(1)) instantiate the constexpr function template foo?

…衆ロ難τιáo~ 提交于 2021-02-07 12:04:49
问题 The following code compiles with with gcc and MSVC, but fails using clang I tested with clang-3.5 and current trunk). template <typename T> constexpr auto wrong = false; template <typename T> constexpr auto foo(const T t) -> int { static_assert(wrong<T>, ""); return {}; } using F = decltype(foo(1)); int main() {} clang instantiates the function body and stumbles over the static_assert . gcc and MSVC just look at the function declaration and ignore the static_assert in the body. If you remove

Why do I get a “404 Not Found” error even though the link is on the server?

对着背影说爱祢 提交于 2021-02-07 12:03:19
问题 I'm running a simple test site on PythonAnywhere using Flask. When I run the script, the initial site (index.html) appears, and everything seems fine. However, when I click on any of the links (like signup.html), I get a 404 error: Not Found The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again. However, the HTML files are all in the templates folder, along with index.html. Why can't they be found on the server? Here is the

Visual Studio Custom Project Template

会有一股神秘感。 提交于 2021-02-07 09:44:07
问题 I have created a Custom C# Project Template for Visual Studio 2008. It works perfect. Only issue is that i have to place the zip file for the project template under the "C:\Documents and Settings\\My Documents\Visual Studio 2008\Templates\ItemTemplates\Visual C#" Now as this folder is specific to each user on the machine, I will have to make sure that all the users on the machine has the project template installed seperately. Is there any way I can just install it once and all the users can

How Can I Modify the Default UnitTest1.cs File Template in the Visual Studio 2010 C# Test Project Template?

你说的曾经没有我的故事 提交于 2021-02-07 09:35:56
问题 I know I can export my own project template, but I'd like to know how to edit the actual, Visual Studio Test Project template's C# UnitTest1.cs file. I've been unable to locate it in my C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE folder tree. Anybody know where this lives so I can modify it? 回答1: Try C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\1033\BasicUnitTest.zip Or C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE

Emulating static constructors for templated classes

最后都变了- 提交于 2021-02-07 09:12:28
问题 I would like to have a templated class with a static data member, and initialize it by emulating a "static constructor." For a non-templated class, this has already been answered (see static constructors in C++? I need to initialize private static objects and What is a static constructor?). However, none of the answers seem to work for a templated class. The following is an example that tries to adapt the "static constructor" idiom from the previous answers to a templated class. (Note that

Emulating static constructors for templated classes

不问归期 提交于 2021-02-07 09:11:32
问题 I would like to have a templated class with a static data member, and initialize it by emulating a "static constructor." For a non-templated class, this has already been answered (see static constructors in C++? I need to initialize private static objects and What is a static constructor?). However, none of the answers seem to work for a templated class. The following is an example that tries to adapt the "static constructor" idiom from the previous answers to a templated class. (Note that

Typedef with template parameter in C++ [duplicate]

走远了吗. 提交于 2021-02-07 09:00:45
问题 This question already has an answer here : C++ template typedef (1 answer) Closed 6 years ago . How can I solve this error? My header file template<typename T> class C1 { public: typedef std::vector<T::F> TFV; TFV Function1(); }; My CPP file template<typename T> TFV C1::Function() //error: ‘TFV’ does not name a type { } 回答1: First of all, use the typename keyword to tell the compiler to interpret F as the (qualified) name of a type: typedef std::vector<typename T::F> TFV; // ^^^^^^^^ Secondly

Typedef with template parameter in C++ [duplicate]

一世执手 提交于 2021-02-07 09:00:37
问题 This question already has an answer here : C++ template typedef (1 answer) Closed 6 years ago . How can I solve this error? My header file template<typename T> class C1 { public: typedef std::vector<T::F> TFV; TFV Function1(); }; My CPP file template<typename T> TFV C1::Function() //error: ‘TFV’ does not name a type { } 回答1: First of all, use the typename keyword to tell the compiler to interpret F as the (qualified) name of a type: typedef std::vector<typename T::F> TFV; // ^^^^^^^^ Secondly