Questions tagged [explicit]

In C++ specifies constructors and conversion operators that don't allow implicit conversions or copy-initialization. In C# declares a user-defined type conversion operator that must be invoked with a cast. For MS SQL Server for-xml-EXPLICIT mode use the [for-xml-explicit] tag

405 questions
8
votes
6 answers

C++ explicit constructors and iterators

Consider the following code: #include struct A { explicit A(int i_) : i(i_) {} int i; }; int main() { std::vector ints; std::vector As(ints.begin(), ints.end()); } Should the above compile? My feeling is that it…
user200783
  • 13,722
  • 12
  • 69
  • 135
8
votes
4 answers

Is there ever an excuse for throwing an Exception from an implicit conversion?

From MSDN: By eliminating unnecessary casts, implicit conversions can improve source code readability. However, because implicit conversions can occur without the programmer's specifying them, care must be taken to prevent unpleasant surprises. In…
Matthew Scharley
  • 127,823
  • 52
  • 194
  • 222
8
votes
2 answers

@Autowired doesn't work if component-scan removed

I'm facing the problem, that the annotation @Autowired doesn't work anymore (in all Java classes that uses this annotation) if I remove the component-scan tag from config
GarfieldKlon
  • 11,170
  • 7
  • 31
  • 33
8
votes
4 answers

Generic explicit cast failure C#

I've some issues with the following piece of code. I would like to explicit a string to an object, this is working perfectly fine, however, if this object is part of a generic class, this is failing with the following error exception: "Unable to…
7
votes
1 answer

Is this example of the use of the C++ 'explicit' keyword correct?

In a GoogleTechTalks video on Youtube, Bjarne Stroustrup talks about the upcoming C++0x standard. In the video he mentions the following example: #include struct Sick { Sick(double d) { std::cout << d << "\n"; } explicit…
Truncheon
  • 916
  • 2
  • 12
  • 25
7
votes
4 answers

Implicit <> Explicit interface

Possible Duplicates: C#: Interfaces - Implicit and Explicit implementation implicit vs explicit interface implementation Hello Can anyone explain me what the difference is between an implicit and explicit interface? Thanks!
Killerwes
  • 292
  • 1
  • 4
  • 14
7
votes
2 answers

Explicit animation of NSView using core animation

I'm trying to slide in a NSView using core animation. I think I need to use explicit animation rather than relying on something like [[view animator] setFrame:newFrame]. This is mainly because I need to set the animation delegate in order to take…
btschumy
  • 1,435
  • 1
  • 18
  • 35
7
votes
2 answers

Android Explicit Intent throws NoClassDefFound error

I'm trying to use an explicit intent to display a MapView in my android app. Although I don't see anything wrong with my code, I keep getting a "NoClassDefFoundError" when I try to start my activity. Basically, from my main activity (SetCriteria),…
joanna
  • 743
  • 3
  • 13
  • 27
7
votes
5 answers

How to solve call ambiguity between Generic.IList.this[] and IList.this[]?

I've got a collection that implements an interface that extends both IList and List. public Interface IMySpecialCollection : IList, IList { ... } That means I have two versions of the indexer. I wish the generic implementation to be…
user1228
7
votes
2 answers

Why is the constructor of std::in_place_t defaulted and explicit?

cppreference shows the following definition of std::in_place_t: struct in_place_t { explicit in_place_t() = default; }; inline constexpr std::in_place_t in_place{}; Why have they added an explicit and defaulted constructor? Why it isn't left…
7
votes
2 answers

When running NUnit and specifying a category, can all uncategorized tests be included too?

We have several hundred test classes, with a few dozen of them marked with the following attributes: [TestFixture] [Explicit] [Category("IntegrationTests")] so they will only be run in our over-night automated build. The remaining…
MTS
  • 131
  • 2
  • 5
7
votes
2 answers

How can I get a compilation error on accidental construction?

Given 2 classes: ... class Grades{ public: Grades(int numExams) : _numExams(numExams){ _grdArr = new double[numExams]; } double GetAverage() const; ... private: // The only data members of the class int _numExams; …
Sanich
  • 1,739
  • 6
  • 25
  • 43
7
votes
1 answer

(involving explicit)Precedence with operator and constructor conversion

I've browsed through a lot of questions related to conversion, but it seemed none of them discussing about explicit keyword in this way. Here's the code: struct B; struct A{ /*explicit*/ A(const B&){ cout << 1; } // *1 }; struct B{ …
Asu
  • 75
  • 4
7
votes
1 answer

When do these load DLLs : Implicit Linking VS Explicit Linking

I thought Implicit linking loads a DLL as soon as the application starts because it is also called "load-time dynamic linking". But I found some strange explanations below from the link…
Jenix
  • 2,996
  • 2
  • 29
  • 58
7
votes
1 answer

iOS - Getting [Explicit] and [Clean] tags from Media in Objective-C

When I view my purchased music in iTunes songs that are explicit are shown with a red explicit box next to them in the list of songs. I.e. the explicit tag you see when purchasing the song is passed through to the iTunes library. Also the same is…
Skanky
  • 129
  • 8