Skip to content

A collection of awful archetypes to ease the testing of generic C++ libraries

License

Notifications You must be signed in to change notification settings

ldionne/libawful

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libawful Travis status

A collection of awful archetypes for testing generic code

Overview

When writing a generic library, one often needs to test generic components with types having infrequent characteristics. This is to make sure that a generic component is not assuming more about its inputs than it should. libawful is a collection of types with unusual properties that can be used to check for corner cases when implementing generic components. The project contains a single header, <awful.hpp>, which defines all the archetypes.

#include <awful.hpp>
#include <utility>

template <typename T, typename U>
struct naive_pair {
  T first;
  U second;

  naive_pair() = default;

  template <typename Other, typename = decltype(std::declval<Other>().first),
                            typename = decltype(std::declval<Other>().second)>
  naive_pair(Other&& other)
    : first(std::forward<Other>(other).first),
      second(std::forward<Other>(other).second)
  { }
};

int main() {
  naive_pair<awful::trapconstructible, int> pair;
  auto copy = pair; // ERROR: naive_pair tries to copy-construct its first
                    //        member from a non-const reference to `pair.first`.
}

Compiler requirements

This is a C++14 library, and no effort whatsoever will be made to accommodate nonconforming compilers.

About

A collection of awful archetypes to ease the testing of generic C++ libraries

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published