Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 24 Apr 2010
Offline Last Active Private

Topics I've Started

Template-related compiler bug or... ?

12 April 2016 - 09:04 PM

In VS 2015 I'm getting an error that I didn't expect and I'm wondering if this is a bug or if it's not expected to work.
The issue itself is trivial. I'd have used a cast in any case to suppress the warning, but I'm wanting to know whether I should report the bug to MS.
Code to recreate:

template <typename T>
struct Foo { T val; };

template <typename T>
Foo<T>& operator*=(Foo<T>& left, T right) {
  left.val *= right;
  return left;

void main() {
  Foo<float> bar;
  bar *= 4; //"no operator *= matches these operands"

I get why it's happening, but I kind of expect that when it doesn't find a float,int signature it will make the effort to check promotions.
Is this standard?

Template Specialization

16 February 2016 - 04:05 AM

I has a function:

template <class T, typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type>
T function(const std::string& requestString) {
  //things happen

Clearly it's only supposed to accept numeric types, but now I want to add a specialization so that it can also handle std::string using different internal logic.


I haven't messed with specialization before, but what I tried based on my reading was this:

template<> std::string function<std::string>(const std::string& requestString) {

The compiler doesn't seem to like that. It says that the template can't match the type. I'm thinking this means that it's upset because std::string isn't arithmetic, as is specified by the original. I figured I should declare an "empty" template (just <class T> and no function body contents) and change the arithmetic one to a specialization, but then (predictably) it complained that <int> was ambiguous between the empty one and the arithmetic one.


Anyone know how I can do this?

Custom environment macro

22 July 2015 - 12:48 PM



I'm using VS2013 and I have a lib that I use to do memory leak checking while debugging that's a little nicer than the crt one. All I have to do to use it is #include it, but I also have to remember to remove the inclusion when I'm done and want to send the code off to someone else. So I figured I should make the inclusion conditional with something like


#ifdef KHATBOX

#include <vld.h>



...but I can't figure out how to define KHATBOX in such a way that it's not going to go along with the project.


Preferably I could set this up once and then have it just be a normal part of my env.


Anyone know if this is possible and how to go about it? I found some stuff about defining environment macros in VS, but that appears to be referring to the path abbreviation crap like $(SolutionDir).

Fixed-size windows

08 July 2015 - 04:42 AM

I'm increasingly seeing this crap, and I'm hereby officially adding it to my list of things that piss me off.


This window is not resizable:






The text that I removed from it is several lines of information, any one of which extends far beyond the width of the text area.


If this were an isolated incident then I'd chalk it up to someone being a moron and move on, but it's happening more and more and more often and it's really starting to rile me up.





I know the rest of you must have pet peeves like this. Let's air the laundry while we're here. What design failures get your goat?

[WinAPI] How can I set the title of my tray icon?

01 January 2015 - 11:07 PM

I'm fiddling with the tray icon stuff in Win7 and I've got it mostly working now, but I noticed something small and annoying that I'd like to fix.
When I click the 'Show Hidden Icons' button in the notification tray, there's a 'Customize' link that opens a window where you can configure what tray icons are hidden and which are displayed, etc. Each Icon is accompanied by a Name and a description. The description is the tooltip text, but I don't see a way to set the Name field. Currently it's just showing the name of the exe.
I'd like to set the Name to a custom value, as I see many of my other applications have done. I had assumed that it would be the title of the window, but apparently this is not the case.

Does anyone know how this can be set?
My source, for anyone interested: