297 questions
0
votes
1
answer
142
views
In Visual Studio 2022 using C#, does Microsoft.Office.Interop.Outlook.Application or Excel.Application implement System.IDisposable?
I have Visual Studio 2022 and this line of code
using (Excel.Application xlApp = new Excel.Application())
throws an error
CS1674 'Application': type used in a using statement must implement 'System....
1
vote
2
answers
93
views
Can a name introduced via using-directive or using-declaration be used as elaborated-type-specifier of a friend declaration?
Why do gcc, clang and msvc successfully compile the following code? (godbolt)
namespace impl {
class A;
} // namespace impl
namespace api {
using namespace impl;
} // namespace api
class B
{
...
1
vote
1
answer
97
views
Unqualified name lookup after using-directives in C++
From cppreference :
From the point of view of unqualified name lookup of any name after a using-directive and until the end of the scope in which it appears, every name from namespace-name is visible ...
0
votes
1
answer
37
views
Type or namespace does not exist. ApplicationName.Models.Model
We're on Visual Studio Code, .NET 8 & Angular.
I changed the structure of my project and now I cannot use using directive in my app, it's driving me crazy.
Here is my structure: Structure
Expended ...
3
votes
1
answer
250
views
Why does using ranges::sort work in a function but not at global namespace when trying to salve ambiguity in calling sort()?
I last used C++ at the 98 with boost/C++11 simulation. I am reading Stroustrup's "A Tour of C++, Third Edition" to help introduct the things I will need to learn more about. Following ...
1
vote
0
answers
47
views
Why is the `using System` directive not necessary here? C# | Visual Studio Code [duplicate]
The C# doc on the using directive says
The using directive allows you to use types defined in a namespace without specifying the fully qualified namespace of that type.
I understood this to mean ...
0
votes
0
answers
25
views
Visual Studio @using statements get altered
I have a VS issue, VS2022 but it also happened in the previous version. In fact its been happening for a few years.
When I do certain operations, often moving files within VS, I find I get a load of ...
-1
votes
1
answer
83
views
#if and #elif doesn't work as intended in Cpp
I am trying to make some sort of easy way to define mcu that I use, and by defining mcu, different header files should be included. I tried doing it with #if and #elif directives :
#include "...
1
vote
1
answer
50
views
Contrasting solutions for visibility when inheriting from base class templates
In the following code will fail to compile because, despite the chain of public inheritance, HasFlag is not visible in DerivedFoo.
class BasicFoo {
public: bool HasFlag() const { return m_flag; }
...
2
votes
1
answer
161
views
gcc 11.3.0 does not find operator despite using directive
The following code (a simplified example from a more complex code) fails to compile with gcc 11.3.0
#include <array>
#include <memory>
#include <tuple>
namespace tools {
template &...
0
votes
0
answers
40
views
Import certain overloads of base class to private scope of derived [duplicate]
Using the using-directive I'm able to select a certain set of methods from the base class to put into a different access scope. Is this also possible for individual overloads of the method? Something ...
-2
votes
2
answers
1k
views
C++ "was not declared in this scope"
Heyo, basically I was writing this simple function to ask you how many cars you have, inputing the amount in the array, and assigning the names of the cars to the array aswell. Also made a for loop to ...
0
votes
0
answers
553
views
How can I reuse "type alias" in another project?
I have a project with some interfaces that contains some type alias in it, for example like below:
namespace UsingTest
{
using MyType = System.Collections.Generic.List<int>;
public ...
1
vote
1
answer
79
views
C# Razor using statements inconsistently require explicit curly brackets
I have a .NET Framework 4.7.2 web application. I am receiving the following yellow screen error from some of my Views and Partial Views but not all of them:
Expected a "{" but found a "...
2
votes
3
answers
98
views
Avoid template mess when importing base class constructors of heavily templated base class
This is just short inquiry if it is at all possible to somehow import base class constructors without all the template bloat. Consider this example where I'm inheriting from a templated std::variant:
...
0
votes
1
answer
33
views
c++ syntax error when specializing nested template of a template parameter [duplicate]
This is what I'm trying to do:
template<typename T, int I>
class A {
public:
using CA = T::C<I>;
};
class B {
public:
template<int I>
struct C {};
};
int main()
{
A&...
16
votes
2
answers
14k
views
How do I control what usings are made global in a C#10 / .NET6.0 project?
C#10 in .NET 6.0 supports a new feature called global using directive.
It seems to do 2 things:
When you have a namespace in the global using, you don't have to include the using ... for that ...
3
votes
1
answer
261
views
using declaration inside a member function for an inherited member field
Inside a function one can employ the using declaration to import a name in the current scope, like
namespace A {
int y;
}
void f() { using A::y; }
A using declaration can be used in a class ...
1
vote
1
answer
381
views
Namespace and Using with 'System' in it
I have a library - Foo.System.Management
I have an application - Foo.New.Application
In this application, Using System; is imported, and what ends up happening is this is being resolved to Foo.System ...
0
votes
1
answer
605
views
Aliasing a generic interface with a using alias directive
I am aware that it's not possible to alias a generic type (e.g. using Foo = Dictionary; is invalid), but that the generic type on the right must be closed (e.g. using Foo = Dictionary<int, string&...
-1
votes
1
answer
67
views
How below macro is working in c programming language? [closed]
Code:
#include <stdio.h>
#define puts "%s C preprocessor"
int main()
{
printf(puts, puts);
return 0;
}
Output:
%s C preprocessor C preprocessor
See also...
Can anyone explain ...
0
votes
0
answers
71
views
Import of Unknown directives dbquery, sdl
I'm using Stepzen, it generated graphql files, however, all of them with errors:
stepzen/index.graphql
schema @sdl(files: ["postgresql/index.graphql"]) {
query: Query
}
stepzen/postgresql/...
0
votes
1
answer
99
views
What's the relevance of the Note in [over.load]/1?
(You might see this question as a duplicate of this, but, to be honest, I've not really understood the matter, so I'm asking separately with my own wording.)
[over.load]/1 reads:
Not all function ...
2
votes
0
answers
46
views
Why can the using directive not be used recursively in c#? [closed]
Why cannot the using directive be used recursively in c#?
using MyKey = System.String;
using MyValue = System.Int32;
using AllowedPair = System.Collections.Generic.KeyValuePair<System.String, ...
1
vote
2
answers
1k
views
Why does StyleCopAnalyzers think that global usings should be declared within a namespace, when such syntax is not possible?
I am creating a NUnit test project and in the creation of that, MS Visual Studio has created a file called Usings.cs with the line
global using NUnit.Framework;
which tells the project to include the ...
3
votes
1
answer
3k
views
error: static assertion failed: template argument must be a complete class or an unbounded array
I'm deriving from a base class in which I try to define a type. That type is dependent on itself via a variant, so it would require to know the memory layout of the base class upon definition. However,...
0
votes
0
answers
39
views
Type alias with "using" inside class cannot be used as return type [duplicate]
I'm currently switching from Java to C++ and I have troubling understaning the following problem.
I have a header file for a class (AClass.h):
#ifndef ACLASS_H
#define ACLASS_H
#include <cstdint&...
0
votes
0
answers
147
views
How do I make my library work with using-directive?
I created a class library with .Net 6.0 which looks like this:
namespace MyLib
{
public static class MyLib {
public static void someFunction() { }
}
}
I created a nuget package and ...
0
votes
2
answers
53
views
simplify using base template class statement
Often in derived template classes I need to refer to the base to access members. I end up writing code like this:
template<typename A>
struct BaseClass
{
};
template<typename B>
struct ...
7
votes
2
answers
433
views
GCC error when using parent class method as derived class method
I have a function in my code which only accepts a class member method as a template parameter. I need to call this method using a class method which is inherited from a parent class. Here is an ...
1
vote
2
answers
2k
views
Using UnityEngine.Animations.Rigging; not found
My Unity project has the Animation Rigging Package. As we all know if we write a script where we need to reference some kind of Rig we must use the namespace/using direction for this package. Here is ...
1
vote
1
answer
168
views
Bring nested name into scope in non-member function
I have a struct B that contains the declaration of a type anchor_point as a nested name. How can I bring anchor_point into scope in another function using the using-directive? I basically want to ...
0
votes
2
answers
628
views
Get template parameter of derived class from base object
In short:
I have a base class A_base without template parameters and a derived class A that has two.
The function foo() only accepts base class objects
foo() is supposed to return an object which has ...
0
votes
1
answer
600
views
working of `line compiler directive in system verilog
Can someone please explain the working of `line compiler directive in system verilog tried to read it's working from LRM but was not able to understand it
2
votes
1
answer
410
views
About the ambiguity of using a name vs using a namespace when doing unqualified calls
I knew that this would be ambiguous
#include <boost/hana/fwd/equal.hpp>
#include <range/v3/algorithm/equal.hpp>
#include <vector>
int main() {
std::vector<int> v{1,2,3};
...
0
votes
1
answer
125
views
Unqualified name lookup does not look in local namespace after using declaration [duplicate]
namespace A
{
int overloaded_f(float some_float);
enum class Enum { Value };
}
namespace B
{
int overloaded_f(A::Enum some_enum);
int f(A::Enum some_enum){
using A::...
2
votes
2
answers
139
views
Impact of namespaces on C++ template deduction priority
while trying to implement a metafunction, which needs to exist only if the "abs" function exists for some type, i ran into the folowing problem:
Here are two examples of code i would expect ...
0
votes
3
answers
3k
views
using ifdef and ifndef directives to include header files
Please excuse my basic question and poor programming knowledge.
I have an implementation that I need to use in many of my projects. But the included header files are different for different projects.
...
4
votes
2
answers
3k
views
What is "using namespace::std" in C++
I am reading some code snippets from others and I find a line:
using namespace::std;
I suspect its purpose is using namespace std;, with some typos. But to my surprise the compiler accepts this code ...
10
votes
1
answer
1k
views
File name convention for C# v10 global using declarations
Is there a consensus within the C# development community on the .cs filename in which global using statements are declared?
I was going to adopt the filename GlobalUsings.cs but then found that a ...
1
vote
3
answers
866
views
can "using namespace std;" and "std::cout" be used together?
No error occurs when using using namespace std; and std::cout together. Can these two be used together?
#include <iostream>
using namespace std;
int main() {
std::cout << "...
2
votes
0
answers
2k
views
Error 'The type or namespace name 'Android' could not be found...' in Visual Studio 2022
I'm getting this error in Visual Studio Community 2022 (64-bit) on Windows 10 Pro:
CS0246 - The type or namespace name 'Android' could not be found (are you missing a using directive or an assembly ...
1
vote
2
answers
167
views
using namespace in c++
I have come to understand why using namespace std; is considered bad practice in c++
but let's consider for example 2 ( hypothetical ) libraries "std" and "sfd" , both of them ...
1
vote
0
answers
54
views
Issues with C++ namespace across file and using directive
Here are a demo code from C++ primer plus about using using-directive and using-declaration across header files and cpp files, I've made some modification to remove the using declarations in other ...
1
vote
2
answers
145
views
Extremely basic question about namespaces in c++
using namespace X;
cout << var;
using Y::var;
cout << var;
So say I have a namespace X and a namespace Y that both contain a variable of type int called var. When I say using ...
1
vote
1
answer
3k
views
How to apply mask to a default value in Typescript
I have a mask-phone directive that works perfectly in the input when the user write a value, but I need to set a default value and I don't know how to apply the mask directive in the component method. ...
1
vote
1
answer
337
views
Passing a nullptr to my overloaded function causes a runtime error
To understand more using directives and function overloading I've tried this program:
namespace ns{
void f(int){cout << "int\n";}
void f(double){cout << "double\n&...
2
votes
2
answers
1k
views
Is there a way to alias a single, static (public) method in C#?
In addition to allowing importing of all types within a namespace, the using directive in C# allows importing of a single type via an alias (e.g. using A = Something.A;) or importing all static ...
2
votes
1
answer
106
views
problem when I separate code to header file [duplicate]
this program works correctly but when I separate that "Class StudentsName" and put it on the header file it doesn't work correctly. I add the header file in my project by right click on the ...
2
votes
1
answer
233
views
Scope of `using namespace` in Unnamed Namespace
Why is the using directive using namespace std; in when enclosed in an anonymous namespace behaves as if it appeared at global scope?
#include <iostream>
namespace x
{
using namespace std;
...