c++11 - Is empty struct defined by C++ standard? -


is there std::empty struct or similar or need define own:

struct empty{}; 

this can used nice in combination std::conditional or other new std features , wonder if standard defines or not.

there no such thing in c++ standard library. mentioned in comments, can still find boost::blank in boost resembles class looking for. if such class existed in standard library, don't think there many third-party libraries defining own struct empty {}.

if want class no data members , smallest possible size - cannot smaller 1 - (and possibly benefit empty base optimization), can still use std::tuple<>. used exact purpose (empty base optimization) in implementation of classes in libstdc++.

if want make sure std::tuple<> empty class:

#include <iostream> #include <tuple> #include <type_traits>  int main() {     // prints 1     std::cout << std::is_empty< std::tuple<> >::value; } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -